Part Number Hot Search : 
BPC2508 MSS12 STD123UF 79S15 01000 P13009 MAX8869 MC145163
Product Description
Full Text Search
 

To Download TSC80C31-30CFB Datasheet File

  If you can't view the Datasheet, Please click here to try to view without PDF Reader .  
 
 


  Datasheet File OCR Text:
  summary atmel's sam4l series is a member of a family of flash microcontrollers based on the high performance 32-bit arm cortex-m4 risc processor running at fre- quencies up to 48mhz. the sam4l series embeds state-of-the-art picopower technology for ultra-low power consumption. combined power control techniques are used to bring active current consumption down to 90a/mhz. the device allows a wide range of options between functionality and power consumption, giving the user the ability to reach the lowest possible power consumption with the feature set required for the application. the wait and retention modes provide full logic and ram retention, associated with fast wake-up capability (<1.5s) and a very low consumption of, respectively, 3 a and 1.5 a. in addition, wait mode sup- ports sleepwalking features. in backup mode, cpu, peripherals and ram are powered off and, while consuming less than 0.9a with external interrupt wake- up supported. the sam4l series offers a wide range of peripherals such as segment lcd con- troller, embedded hardware capacitive touch (qtouch), usb device & embedded host, 128-bit aes and audio interfaces in addition to high spee d serial peripher- als such as usart, spi and i 2 c. additionally the peripheral event system and sleepwalking allows the peripherals to communicate directly with each other and make intelligent decisions and decide to wake-up the system on a qualified events on a peripheral level; such as i 2 c address match or and adc threshold. features ? core ? arm ? cortex tm -m4 running at up to 48mhz ? memory protection unit (mpu) ?thumb ? -2 instruction set ? picopower ? technology for ultra-low power consumption ? active mode downto 90a/mhz with configurable voltage scaling ? high performance and efficiency: 28 coremark/ma ? wait mode downto 3a with fast wake-up time (<1.5s) supporting sleepwalking ? full ram and logic retention mode downto 1.5a with fast wa ke-up time (<1.5s) ? ultra low power backup mode with/without rtc downto 1,5/0.9a ? memories ? from 128 to 512kbytes embedded flash, 64-bit wide access, ? 0 wait-state capa bility up to 24mhz ? up to 64kbytes embedded sram ? system functions ? embedded voltage linear and switching regulator for single supply operation ? two power-on-reset and two brown-out detectors (bod) ? quartz or ceramic resonator oscillators: 0.6 to 30mhz main power with failure detection and low power 32.768 khz for rtc or device clock ? high precision 4/8/12mhz factory trimmed internal rc oscillator ? slow clock internal rc o scillator as permanent low-power mode device clock ? high speed 80mhz internal rc oscillator ? low power 32khz internal rc oscillator ? pll up to 240mhz for device clock and for usb 42023e?07/2013 atsam ---e arm-based flash mcu sam4l series
2 42023e?sam?07/2013 atsam4l8/l4/l2 ? digital frequency locked loop (dfll) with wide input range ? up to 16 peripheral dma (pdca) channels ? peripherals ? usb 2.0 device and embedded host: 12 mbps, up to 8 bidirectional endpoints and multi-packet ping-pong mode. on- chip transceiver ? liquid crystal display (l cd) module with capacity up to 40 se gments and up to 4 common terminals ? one usart with iso7816, irda?, rs-485, spi, manchester and lin mode ? three usart with spi mode ? one picouart for extended uart wa ke-up capabilities in all sleep modes ? windowed watchdog timer (wdt) ? asynchronous timer (ast) with real-time clock ca pability, counter or ca lendar mode supported ? frequency meter (freqm) for accurate measuring of clock frequency ? six 16-bit timer/counter (tc) channels wi th capture, waveform, compare and pwm mode ? one master/slave serial peripheral inte rface (spi) with ch ip select signals ? four master and two slave two-wire in terfaces (twi), up to 3.4mbit/s i 2 c-compatible ? one advanced encryption system (aes) with 128-bit key length ? one 16-channel adc 300ksps (adc) with up to 12 bits resolution ? one dac 500ksps (dacc) with up to 10 bits resolution ? four analog comparators (acifc) with optional window detection ? capacitive touch module (catb) supporting up to 32 buttons ? audio bitstream dac (abdacb) suitable for stereo audio ? inter-ic sound (iisc) controller, compliant with inter-ic sound (i 2 s) specification ? peripheral event system for direct pe ripheral to periph eral communication ? 32-bit cyclic redundancy ch eck calculation unit (crccu) ? random generator (trng) ? parallel capture module (parc) ? glue logic controller (gloc) ? i/o ? up to 75 i/o lines with external interr upt capability (edge or level sensitivity), debouncing, glitch filtering and slew-rate control ? up to six high-drive i/o pins ? single 1.68-3.6v power supply ? packages ? 100-lead lqfp, 14 x 14 mm, pitch 0.5 mm/100-ball vfbga, 7x7 mm, pitch 0.65 mm ? 64-lead lqfp, 10 x 10 mm, pitch 0.5 mm/64-pad qfn 9x9 mm, pitch 0.5 mm ? 64-ball wlcsp, 4,314x4,434 mm, pitch 0.5 mm ? 48-lead lqfp, 7 x 7 mm, pitch 0.5 mm/48-pad qfn 7x7 mm, pitch 0.5 mm
3 42023e?sam?07/2013 atsam4l8/l4/l2 1. description atmel's sam4l series is a member of a family of flash microcontrollers based on the high per- formance 32-bit arm cortex-m4 risc processor running at frequencies up to 48mhz. the processor implements a memory protection unit (mpu) and a fast and flexible interrupt con- troller for supporting modern and real-time operating systems. the atsam4l8/l4/l2 embeds state-of-the-art picopower technology for ultra-low power con- sumption. combined power control techniques are used to bring active current consumption down to 90a/mhz. the device allows a wide range of options between functionality and power consumption, giving the user th e ability to reach the lowest po ssible power consumption with the feature set required for the application. on-chi p regulator improves pow er efficiency when used in swichting mode with an external inductor or can be used in linear mode if application is noise sensitive. the atsam4l8/l4/l2 supports 4 power saving strategies. the sleep mode put the cpu in idle mode and offers different sub-modes which automatically switch off/on bus clocks, pll, oscillators. the wait and retention modes prov ide full logic and ram retention, associated with fast wake-up capability (<1.5 s) and a very low consumption of, respectively, 3 a and 1.5 a. in addition, wait mode supports sleepwalking features. in backup mode, cpu, peripher- als and ram are powered off and, while consuming less than 0.5a, the device is able to wake- up from external interrupts. the atsam4l8/l4/l2 incorporates on-chip flash tightly coupled to a low power cache (lpcache) for active consumption optimization and sram memories for fast access. the lcd controller is intended for monochrome passive liquid crystal display (lcd) with up to 4 common terminals and up to 40 segments terminals. dedicated low power waveform, con- trast control, extended interrupt mode, selectable frame frequency and blink functionality are supported to offload the cpu, reduce interrupts and reduce power consumption. the lcd includes integrated lcd buffers, an integrated power supply voltage and an innovative swap mode. using swap mode, the hardware designers have more flexibility during board layout as they can rearrange the pin sequence on segment and/or common terminal buses. the low-power and high performance capacitive touch module (catb) is introduced to meet the demand for a low power capacitive touch solution that could be used to handle buttons, sliders and wheels. the catb provides excellent si gnal performance, as well as autonomous touch and proximity detection for up to 32 sensors. this solution includes an advanced sequencer in addition to an hardware filtering unit. the advanced encryption standard module (aesa) is compliant with the fips (federal infor- mation processing standard) publication 197, advanced encryption standard (aes) , which specifies a symmetric block cipher that is used to encrypt and decrypt electronic data. encryp- tion is the transformation of a usable message, called the plaintext , into an unreadable form, called the ciphertext . on the other hand, decryption is the transformation that recovers the plain- text from the ciphertext. aesa supports 128 bits cryptographi c key sizes. the peripheral direct memory access (dma) controller enables data transfers between periph- erals and memories without processor involvement. the peripheral dma controller drastically reduces processing overhead when transferring continuous and large data streams. the peripheral event system (pes) allows peripherals to receive, react to, and send peripheral events without cpu intervention. asynchronous interrupts allow advanced peripheral operation in low power modes.
4 42023e?sam?07/2013 atsam4l8/l4/l2 the power manager (pm) improves design flexibility and securi ty. the power ma nager supports sleepwalking functionality, by which a module can be selectively activated based on peripheral events, even in sleep modes where the module clock is stopped. power monitoring is supported by on-chip power-on reset (por18, por33), brown-out detectors (bod18, bod33). the device features several oscillators, such as phase locked loop (pll), digital frequency locked loop (dfll), oscillator 0 (osc0), internal rc 4,8,12mh z oscillator (rcfast), system rc oscillator (rcsys), internal rc 80mhz, in ternal 32khz rc and 32khz crystal oscillator. either of these oscillators can be used as source for the system clock. the dfll is a program- mable internal oscillator from 40 to 150mhz. it can be tuned to a high accuracy if an accurate reference clock is running, e.g. the 32khz crystal oscillator. the watchdog timer (wdt) will reset the device unless it is periodically serviced by the soft- ware. this allows the device to recover from a condition that has caused the system to be unstable. the asynchronous timer (ast) combined with the 32khz crystal oscillator supports powerful real-time clock capabilities, with a maximum timeou t of up to 136 years. the ast can operate in counter or calendar mode. the frequency meter (freqm) allows accurate measuring of a clock frequency by comparing it to a known reference clock. the full-speed usb 2.0 device and embedded host interface (usbc) supports several usb classes at the same ti me utilizing the rich en d-point configuration. the device includes six identical 16-bit timer/counter (tc) channels. each channel can be inde- pendently programmed to perform frequency measurement, event counting, interval measurement, pulse generation, delay timing, and pulse width modulation. the atsam4l8/l4/l2 also features many communi cation interfaces, like usart, spi, or twi, for communication intensive applications. the usart supports different communication modes, like spi mode and lin mode. a general purpose 16-channel adc is provided, as well as four analog comparators (acifc). the adc can operate in 12-bit mode at full speed. the analog comparators can be paired to detect when the sensing voltage is within or outside the defined reference window. atmel offers the qtouch library for embedding capacitive touch buttons, sliders, and wheels functionality. the patented charge-transfer signal acquisition offers robust sensing and includes fully debounced reporting of touch keys as well as adjacent key suppression ? (aks ? ) technol- ogy for unambiguous detection of key events. the easy-to-use qtouch suite toolchain allows you to explore, develop, and debug your own touch applications. the audio bitstream dac (abdacb) converts a 16- bit sample value to a digital bitstream with an average value proportional to the sample value. two channels are supported, making the abdac particularly suitable for stereo audio. the inter-ic sound controller (iis c) provides a 5-bit wide, bidi rectional, synchronous, digital audio link with external audio devices. the controll er is compliant with the inter-ic sound (i2s) bus specification.
5 42023e?sam?07/2013 atsam4l8/l4/l2 2. overview 2.1 block diagram figure 2-1. block diagram biasl,biash caph,capl asynchronous timer peripheral dma controller hsb-pb bridge b hsb-pb bridge a s mm sm external interrupt controller high speed bus matrix generalpurpose i/os general purpose i/os pa pb pc extint[8..1] nmi pa pb pc spi dma miso, mosi npcs[3..0] usart0 usart1 usart2 usart3 dma rxd txd clk rts, cts watchdog timer sck jtag & serial wire tdo tdi tms configuration registers bus s arm cortex-m4 processor fmax 48 mhz in-circuit emulator nvic twi master 0 twi master 1 twi master 2 twi master 3 dma twi slave 0 twi slave 1 dma reset controller sleep controller clock controller tck twck twd twck twd usbc 8 endpoints dma inter-ic sound controller audio bitstream dac dma abdac[1..0] abdacn[1..0] isck iws isdi isdo imck clk m s d m dp system control interface gclk[3:0] vddcore vddout rcsys x i n 0 x o u t 0 osc0 dfll rc32k pll gclk_in[1:0] s memory protection unit instruction/ data system system tap hsb-pb bridge d s power manager resetn backup system control interface backup registers capacitive touch module backup power manager ldo/ switching regulator dma sense[69..0] dis glue logic controller in[7..0] out[1..0] timer/counter 0 timer/counter 1 a[2..0] b[2..0] clk[2..0] frequency meter 16-channel 12-bit adc interface dma trigger ad[14..0] advrefp ac interface acrefn acan[3..0] acap[3..0] hsb-pb bridge c rcfast parallel capture controller s backup domain pcck dma 32-bit crc calculation unit vddin true random generator 10-bit dac interface dma dacout picouart rxd pcen1,pcen2 pcdata[7..0] lcd controller seg[39..0] com[3..0] dma 128-bit aes s dma flash controller low power cache 512/256/128 kb flash hram controller 64/32 kb ram system management access port rc80m x i n 3 2 x o u t 3 2 osc32 peripheral event controller pad_evt[3..0] generic clock
6 42023e?sam?07/2013 atsam4l8/l4/l2 2.2 configuration summary table 2-1. sub series summary feature atsam4lc atsam4ls segment lcd yes no aesa yes no usb device + host device only table 2-2. configuration summary feature atsam4lxxc/ atsam4lxxb atsam4lxxa number of pins 100 64 48 max frequency 48mhz flash 512/256/128kb sram 64/32/32kb segment lcd 4x40 (1) 4x23 (1) 4x13 (1) gpio 75 (1) 43 (1) 27 (1) high-drive pins 6 3 1 external interrupts 8 + 1 nmi twi 2 masters + 2 masters/slaves 1 master + 1 master/slave usart 4 3 in lc sub series 4 in ls sub series picouart 1 peripheral dma channels 16 aesa 1 peripheral event system 1 spi 1 asynchronous timers 1 timer/counter channels 6 3 parallel capture inputs 8 frequency meter 1 watchdog timer 1 power manager 1 glue logic lut 2 1
7 42023e?sam?07/2013 atsam4l8/l4/l2 notes: 1. for atsam4ls sub serie, no lcd segment pins are available and 5 additionnal gpio pins are available. oscillators digital frequency locked loop 20-150mhz (dfll) phase locked loop 48-240mhz (pll) crystal oscillator 0.6-30mhz (osc0) crystal oscillator 32khz (osc32k) rc oscillator 80mhz (rc80m) rc oscillator 4,8,12mhz (rcfast) rc oscillator 115khz (rcsys) rc oscillator 32khz (rc32k) adc 15-channel 7-channel 3-channel dac 1-channel analog comparators 4 2 1 catb sensors 32 32 26 usb 1 audio bitstream dac 1 iis controller 1 packages tqfp/vfbga tqfp/qfn/ wlcsp tqfp/qfn table 2-2. configuration summary feature atsam4lxxc/ atsam4lxxb atsam4lxxa
8 42023e?sam?07/2013 atsam4l8/l4/l2 3. package and pinout 3.1 package the device pins are multiplexed with peripheral functions as described in section 3.2 ?peripheral multiplexing on i/o lines? on page 18 . 3.1.1 atsam4lcx pinout figure 3-1. atsam4lc tqfp100 pinout pc00 1 pc01 2 pc02 3 pc03 4 pa00 5 pa01 6 gnd 7 vddio 8 pc04 9 pc05 10 pc06 11 pa02 12 reset_n 13 vddcore 14 gnd 15 vddout 16 vddin 17 tck 18 pa03 19 pb00 20 pb01 21 pb02 22 pb03 23 pa04 24 pa05 25 xin32 26 xout32 27 pb04 28 pb05 29 pa06 30 pa07 31 advrefn 32 gndana 33 advrefp 34 vddana 35 pc07 36 pc08 37 pc09 38 pc10 39 pc11 40 pc12 41 pc13 42 pc14 43 pa08 44 pb06 45 pb07 46 pa09 47 pa10 48 pa11 49 pa12 50 pb11 75 pb10 74 pb09 73 pb08 72 pc23 71 pc22 70 pc21 69 pc20 68 pa17 67 pa16 66 pa15 65 pa14 64 pa13 63 pc19 62 pc18 61 pc17 60 pc16 59 pc15 58 vlcdin 57 gnd 56 biasl 55 biash 54 vlcd 53 capl 52 caph 51 pa18 76 pa19 77 pa20 78 pc24 79 pc25 80 pc26 81 pc27 82 pc28 83 pc29 84 pc30 85 pc31 86 vddio 87 vddio 88 pb12 89 pb13 90 pa21 91 pa22 92 pb14 93 pb15 94 pa23 95 pa24 96 vddio 97 pa25 98 pa26 99 gnd 100
9 42023e?sam?07/2013 atsam4l8/l4/l2 figure 3-2. atsam4lc vfbga100 pinout 10 9 8 7 6 5 4 3 2 1 a b c d e f g h j k vdd core vddout pa05 gnd vddin pa04 pc00 gnd vddio pa02 xin32 xout32 pb04 pb05 pa06 pa07 gndana ad vrefp pc07 pc08 pc09 pc10 pc11 pc12 pc13 pc14 pa08 pb06 pb07 pa09 pa10 pa11 pa12 caph capl vlcd biash biasl gnd vlcdin pc15 pc16 pc17 pc18 pc19 pa13 pa14 pa15 pa16 pa17 pc20 pc21 pc22 pc23 pb08 pb09 pb10 pb11 pa18 pa19 pa20 pc24 pc25 pc26 pc27 pc28 pc29 pc30 pc31 vddio vddio pb12 pb13 pa21 pa22 pb14 pb15 pa23 pa24 vddio pa25 pa26 gnd pc01 pc02 pc03 pa00 pa01 pc04 pc05 pc06 reset_n tck pa03 pb00 pb01 pb02 pb03 ad vrefn vddana
10 42023e?sam?07/2013 atsam4l8/l4/l2 figure 3-3. atsam4lc wlcsp64 pinout 8 7 6 5 4 3 2 1 a b c d e f g h capl pa09 pb04 ad vrefp vddana gndana pa12 caph xin32 pb01 vddin pb03 pa05 pa04 pb00 pa03 tck pb02 vdd core pb05 reset_n pa02 pb14 gnd pa26 pa24 vddio pa22 pa25 pa23 pb15 pa00 pa21 pa01 vddio pa20 pb11 pa19 pa18 pa17 pb10 pa16 vlcdin pb09 pa15 gnd pa14 biasl pb08 biash pa13 pa11 vlcd pa07 pb07 pa10 pb06 pa08 xout32 pb12 pb13 pa06 vddout gnd
11 42023e?sam?07/2013 atsam4l8/l4/l2 figure 3-4. atsam4lc tqfp64/qfn64 pinout pa00 1 pa01 2 pa02 3 reset_n 4 vddcore 5 gnd 6 vddout 7 vddin 8 tck 9 pa03 10 pb00 11 pb01 12 pb02 13 pb03 14 pa04 15 pa05 16 xin32 17 xout32 18 pb04 19 pb05 20 pa06 21 pa07 22 gndana 23 advrefp 24 vddana 25 pa08 26 pb06 27 pb07 28 pa09 29 pa10 30 pa11 31 pa12 32 pb11 48 pb10 47 pb09 46 pb08 45 pa17 44 pa16 43 pa15 42 pa14 41 pa13 40 vlcdin 39 gnd 38 biasl 37 biash 36 vlcd 35 capl 34 caph 33 pa18 49 pa19 50 pa20 51 vddio 52 pb12 53 pb13 54 pa21 55 pa22 56 pb14 57 pb15 58 pa23 59 pa24 60 vddio 61 pa25 62 pa26 63 gnd 64
12 42023e?sam?07/2013 atsam4l8/l4/l2 figure 3-5. atsam4lc tqfp48/qfn48 pinout pa00 1 pa01 2 pa02 3 reset_n 4 vddcore 5 gnd 6 vddout 7 vddin 8 tck 9 pa03 10 pa04 11 pa05 12 xin32 13 xout32 14 pa06 15 pa07 16 gndana 17 advrefp 18 vddana 19 pa08 20 pa09 21 pa10 22 pa11 23 pa12 24 pa17 36 pa16 35 pa15 34 pa14 33 pa13 32 vlcdin 31 gnd 30 biasl 29 biash 28 vlcd 27 capl 26 caph 25 pa18 37 pa19 38 pa20 39 vddio 40 pa21 41 pa22 42 pa23 43 pa24 44 vddio 45 pa25 46 pa26 47 gnd 48
13 42023e?sam?07/2013 atsam4l8/l4/l2 3.1.2 atsam4lsx pinout figure 3-6. atsam4ls tqfp100 pinout pc00 1 pc01 2 pc02 3 pc03 4 pa00 5 pa01 6 gnd 7 vddio 8 pc04 9 pc05 10 pc06 11 pa02 12 reset_n 13 vddcore 14 gnd 15 vddout 16 vddin 17 tck 18 pa03 19 pb00 20 pb01 21 pb02 22 pb03 23 pa04 24 pa05 25 xin32 26 xout32 27 pb04 28 pb05 29 pa06 30 pa07 31 advrefn 32 gndana 33 advrefp 34 vddana 35 pc07 36 pc08 37 pc09 38 pc10 39 pc11 40 pc12 41 pc13 42 pc14 43 pa08 44 pb06 45 pb07 46 pa09 47 pa10 48 pa11 49 pa12 50 pb11 75 pb10 74 pb09 73 pb08 72 pc23 71 pc22 70 pc21 69 pc20 68 pa17 67 pa16 66 pa15 65 pa14 64 pa13 63 pc19 62 pc18 61 pc17 60 pc16 59 pc15 58 pa31 57 pa30 56 vddio 55 gnd 54 pa29 53 pa28 52 pa27 51 pa18 76 pa19 77 pa20 78 pc24 79 pc25 80 pc26 81 pc27 82 pc28 83 pc29 84 pc30 85 pc31 86 vddio 87 vddio 88 pb12 89 pb13 90 pa21 91 pa22 92 pb14 93 pb15 94 pa23 95 pa24 96 vddio 97 pa25 98 pa26 99 gnd 100
14 42023e?sam?07/2013 atsam4l8/l4/l2 figure 3-7. atsam4ls vfbga100 pinout 10 9 8 7 6 5 4 3 2 1 a b c d e f g h j k vdd core vddout pa05 gnd vddin pa04 pc00 gnd vddio pa02 xin32 xout32 pb04 pb05 pa06 pa07 gndana ad vrefp pc07 pc08 pc09 pc10 pc11 pc12 pc13 pc14 pa08 pb06 pb07 pa09 pa10 pa11 pa12 pa27 pa28 pa29 gnd vddio pa30 pa31 pc15 pc16 pc17 pc18 pc19 pa13 pa14 pa15 pa16 pa17 pc20 pc21 pc22 pc23 pb08 pb09 pb10 pb11 pa18 pa19 pa20 pc24 pc25 pc26 pc27 pc28 pc29 pc30 pc31 vddio vddio pb12 pb13 pa21 pa22 pb14 pb15 pa23 pa24 vddio pa25 pa26 gnd pc01 pc02 pc03 pa00 pa01 pc04 pc05 pc06 reset_n tck pa03 pb00 pb01 pb02 pb03 ad vrefn vddana
15 42023e?sam?07/2013 atsam4l8/l4/l2 figure 3-8. atsam4ls wlcsp64 pinout 8 7 6 5 4 3 2 1 a b c d e f g h pa28 pa09 pb04 ad vrefp vddana gndana pa12 pa27 xin32 pb01 vddin pb03 pa05 pa04 pb00 pa03 tck pb02 vdd core pb05 reset_n pa02 pb14 gnd pa26 pa24 vddio pa22 pa25 pa23 pb15 pa00 pa21 pa01 vddio pa20 pb11 pa19 pa18 pa17 pb10 pa16 pa31 pb09 pa15 pa30 pa14 vddio pb08 gnd pa13 pa11 pa29 pa07 pb07 pa10 pb06 pa08 xout32 pb12 pb13 pa06 vddout gnd
16 42023e?sam?07/2013 atsam4l8/l4/l2 figure 3-9. atsam4ls tqfp64/qfn64 pinout pa00 1 pa01 2 pa02 3 reset_n 4 vddcore 5 gnd 6 vddout 7 vddin 8 tck 9 pa03 10 pb00 11 pb01 12 pb02 13 pb03 14 pa04 15 pa05 16 xin32 17 xout32 18 pb04 19 pb05 20 pa06 21 pa07 22 gndana 23 advrefp 24 vddana 25 pa08 26 pb06 27 pb07 28 pa09 29 pa10 30 pa11 31 pa12 32 pb11 48 pb10 47 pb09 46 pb08 45 pa17 44 pa16 43 pa15 42 pa14 41 pa13 40 pa31 39 pa30 38 vddio 37 gnd 36 pa29 35 pa28 34 pa27 33 pa18 49 pa19 50 pa20 51 vddio 52 pb12 53 pb13 54 pa21 55 pa22 56 pb14 57 pb15 58 pa23 59 pa24 60 vddio 61 pa25 62 pa26 63 gnd 64
17 42023e?sam?07/2013 atsam4l8/l4/l2 figure 3-10. atsam4ls tqfp48/qfn48 pinout see section 3.3 ?signals description? on page 30 for a description of the various peripheral signals. refer to ?electrical characteristics? on page 1120 for a description of the electrical properties of the pin types used. pa00 1 pa01 2 pa02 3 reset_n 4 vddcore 5 gnd 6 vddout 7 vddin 8 tck 9 pa03 10 pa04 11 pa05 12 xin32 13 xout32 14 pa06 15 pa07 16 gndana 17 advrefp 18 vddana 19 pa08 20 pa09 21 pa10 22 pa11 23 pa12 24 pa17 36 pa16 35 pa15 34 pa14 33 pa13 32 pa31 31 pa30 30 vddio 29 gnd 28 pa29 27 pa28 26 pa27 25 pa18 37 pa19 38 pa20 39 vddio 40 pa21 41 pa22 42 pa23 43 pa24 44 vddio 45 pa25 46 pa26 47 gnd 48
18 42023e?sam?07/2013 atsam4l8/l4/l2 3.2 peripheral multiplexing on i/o lines 3.2.1 multiplexed signals each gpio line can be assigned to one of the peripheral functions. the following tables ( section 3-1 ?100-pin gpio controller function multiplexing? on page 18 to section 3-4 ?48-pin gpio controller function mult iplexing? on page 27 ) describes the peripheral signals multiplexed to the gpio lines. peripheral functions that are not relevant in some parts of the family are grey-shaded. for description of differents s upply voltage source, refer to the section 5. ?power and startup considerations? on page 42 . table 3-1. 100-pin gpio controller function multiplexing (sheet 1 of 4) atsam4lc atsam4ls pin gpio supply gpio functions qfn vfbga qfn vfbga abcdefg 5 b9 5 b9 pa00 0 vddio 6 b8 6 b8 pa01 1 vddio 12 a7 12 a7 pa02 2 vddin s c i f gclk0 s p i npcs0 c a t b dis 19 b3 19 b3 pa03 3 vddin s p i miso 24 a2 24 a2 pa04 4 vddana a d c i f e ad0 u s a r t 0 clk e i c extint2 g l o c in1 c a t b sense0 25 a1 25 a1 pa05 5 vddana a d c i f e ad1 u s a r t 0 rxd e i c extint3 g l o c in2 a d c i f e trigger c a t b sense1 30 c3 30 c3 pa06 6 vddana d a c c vout u s a r t 0 rts e i c extint1 g l o c in0 a c i f c acan0 c a t b sense2 31 d3 31 d3 pa07 7 vddana a d c i f e ad2 u s a r t 0 txd e i c extint4 g l o c in3 a c i f c acap0 c a t b sense3 44 g2 44 g2 pa08 8 lcda u s a r t 0 rts t c 0 a0 pevc pad evt0 g l o c out0 lcdca seg23 c a t b sense4 47 f5 47 f5 pa09 9 lcda u s a r t 0 cts t c 0 b0 pevc pad evt1 pa r c pcdata0 lcdca com3 c a t b sense5 48 h2 48 h2 pa10 10 lcda u s a r t 0 clk t c 0 a1 pevc pad evt2 pa r c pcdata1 lcdca com2 c a t b sense6 49 h3 49 h3 pa11 11 lcda u s a r t 0 rxd t c 0 b1 pevc pad evt3 pa r c pcdata2 lcdca com1 c a t b sense7 50 j2 50 j2 pa12 12 lcda u s a r t 0 txd t c 0 a2 pa r c pcdata3 lcdca com0 c a t b dis 63 h5 63 h5 pa13 13 lcda u s a r t 1 rts t c 0 b2 s p i npcs1 pa r c pcdata4 lcdca seg5 c a t b sense8 64 k7 64 k7 pa14 14 lcda u s a r t 1 clk t c 0 clk0 s p i npcs2 pa r c pcdata5 lcdca seg6 c a t b sense9 65 g5 65 g5 pa15 15 lcda u s a r t 1 rxd t c 0 clk1 s p i npcs3 pa r c pcdata6 lcdca seg7 c a t b sense10
19 42023e?sam?07/2013 atsam4l8/l4/l2 66 j7 66 j7 pa16 16 lcda u s a r t 1 txd t c 0 clk2 e i c extint1 pa r c pcdata7 lcdca seg8 c a t b sense11 67 h6 67 h6 pa17 17 lcda u s a r t 2 rts a b d a c b dac0 e i c extint2 pa r c pcck lcdca seg9 c a t b sense12 76 k10 76 k10 pa18 18 lcda u s a r t 2 clk a b d a c b dacn0 e i c extint3 pa r c pcen1 lcdca seg18 c a t b sense13 77 j10 77 j10 pa19 19 lcda u s a r t 2 rxd a b d a c b dac1 e i c extint4 pa r c pcen2 s c i f gclk0 lcdca seg19 c a t b sense14 78 h10 78 h10 pa20 20 lcda u s a r t 2 txd a b d a c b dacn1 e i c extint5 g l o c in0 s c i f gclk1 lcdca seg20 c a t b sense15 91 e9 91 e9 pa21 21 lcdc s p i miso u s a r t 1 cts e i c extint6 g l o c in1 t w i m 2 twd lcdca seg34 c a t b sense16 92 e10 92 e10 pa22 22 lcdc s p i mosi u s a r t 2 cts e i c extint7 g l o c in2 t w i m 2 twck lcdca seg35 c a t b sense17 95 d6 95 d6 pa23 23 lcdc s p i sck t w i m s 0 twd e i c extint8 g l o c in3 s c i f gclk in0 lcdca seg38 c a t b dis 96 d10 96 d10 pa24 24 lcdc s p i npcs0 t w i m s 0 twck g l o c out0 s c i f gclk in1 lcdca seg39 c a t b sense18 98 d9 98 d9 pa25 25 vddio u s b c dm u s a r t 2 rxd c a t b sense19 99 c9 99 c9 pa26 26 vddio u s b c dp u s a r t 2 txd c a t b sense20 51 k1 pa27 27 lcda s p i miso i i s c isck a b d a c b dac0 g l o c in4 u s a r t 3 rts c a t b sense0 52 j1 pa28 28 lcda s p i mosi i i s c isdi a b d a c b dacn0 g l o c in5 u s a r t 3 cts c a t b sense1 53 k2 pa29 29 lcda s p i sck i i s c iws a b d a c b dac1 g l o c in6 u s a r t 3 clk c a t b sense2 56 k4 pa30 30 lcda s p i npcs0 i i s c isdo a b d a c b dacn1 g l o c in7 u s a r t 3 rxd c a t b sense3 57 k5 pa31 31 lcda s p i npcs1 i i s c imck a b d a c b clk g l o c out1 u s a r t 3 txd c a t b dis 20 j3 20 j3 pb00 32 vddin t w i m s 1 twd u s a r t 0 rxd c a t b sense21 21 d5 21 d5 pb01 33 vddin t w i m s 1 twck u s a r t 0 txd e i c extint0 c a t b sense22 22 e5 22 e5 pb02 34 vddana a d c i f e ad3 u s a r t 1 rts a b d a c b dac0 i i s c isck a c i f c acbn0 c a t b sense23 23 c4 23 c4 pb03 35 vddana a d c i f e ad4 u s a r t 1 clk a b d a c b dacn0 i i s c isdi a c i f c acbp0 c a t b dis 28 c1 28 c1 pb04 36 vddana a d c i f e ad5 u s a r t 1 rxd a b d a c b dac1 i i s c isdo d a c c ext trig0 c a t b sense24 29 b1 29 b1 pb05 37 vddana a d c i f e ad6 u s a r t 1 txd a b d a c b dacn1 i i s c imck c a t b sense25 45 g3 45 g3 pb06 38 lcda u s a r t 3 rts g l o c in4 i i s c iws lcdca seg22 c a t b sense26 46 h1 46 h1 pb07 39 lcda u s a r t 3 cts g l o c in5 t c 0 a0 lcdca seg21 c a t b sense27 table 3-1. 100-pin gpio controller function multiplexing (sheet 2 of 4) atsam4lc atsam4ls pin gpio supply gpio functions qfn vfbga qfn vfbga abcdefg
20 42023e?sam?07/2013 atsam4l8/l4/l2 72 g6 72 g6 pb08 40 lcda u s a r t 3 clk g l o c in6 t c 0 b0 lcdca seg14 c a t b sense28 73 g7 73 g7 pb09 41 lcda u s a r t 3 rxd p e v c pad evt2 g l o c in7 t c 0 a1 lcdca seg15 c a t b sense29 74 g8 74 g8 pb10 42 lcda u s a r t 3 txd p e v c pad evt3 g l o c out1 t c 0 b1 s c i f gclk0 lcdca seg16 c a t b sense30 75 k9 75 k9 pb11 43 lcda u s a r t 0 cts s p i npcs2 t c 0 a2 s c i f gclk1 lcdca seg17 c a t b sense31 89 e7 89 e7 pb12 44 lcdc u s a r t 0 rts s p i npcs3 pevc pad evt0 t c 0 b2 s c i f gclk2 lcdca seg32 c a t b dis 90 e8 90 e8 pb13 45 lcdc u s a r t 0 clk s p i npcs1 pevc pad evt1 t c 0 clk0 s c i f gclk3 lcdca seg33 c a t b sense0 93 d7 93 d7 pb14 46 lcdc u s a r t 0 rxd s p i miso t w i m 3 twd t c 0 clk1 s c i f gclk in0 lcdca seg36 c a t b sense1 94 d8 94 d8 pb15 47 lcdc u s a r t 0 txd s p i mosi t w i m 3 twck t c 0 clk2 s c i f gclk in1 lcdca seg37 c a t b sense2 1 a10 1 a10 pc00 64 vddio s p i npcs2 u s a r t 0 clk t c 1 a0 c a t b sense3 2 c8 2 c8 pc01 65 vddio s p i npcs3 u s a r t 0 rts t c 1 b0 c a t b sense4 3 c7 3 c7 pc02 66 vddio s p i npcs1 u s a r t 0 cts u s a r t 0 rxd t c 1 a1 c a t b sense5 4 b7 4 b7 pc03 67 vddio s p i npcs0 e i c extint5 u s a r t 0 txd t c 1 b1 c a t b sense6 9 c5 9 c5 pc04 68 vddio s p i miso e i c extint6 t c 1 a2 c a t b sense7 10 c6 10 c6 pc05 69 vddio s p i mosi e i c extint7 t c 1 b2 c a t b dis 11 b6 11 b6 pc06 70 vddio s p i sck e i c extint8 t c 1 clk0 c a t b sense8 36 f2 36 f2 pc07 71 vddana a d c i f e ad7 u s a r t 2 rts pevc pad evt0 t c 1 clk1 c a t b sense9 37 e3 37 e3 pc08 72 vddana a d c i f e ad8 u s a r t 2 clk pevc pad evt1 t c 1 clk2 u s a r t 2 cts c a t b sense10 38 f1 38 f1 pc09 73 vddana a d c i f e ad9 u s a r t 3 rxd a b d a c b dac0 i i s c isck a c i f c acan1 c a t b sense11 39 d4 39 d4 pc10 74 vddana a d c i f e ad10 u s a r t 3 txd a b d a c b dacn0 i i s c isdi a c i f c acap1 c a t b sense12 40 e4 40 e4 pc11 75 vddana a d c i f e ad11 u s a r t 2 rxd pevc pad evt2 c a t b sense13 41 f3 41 f3 pc12 76 vddana a d c i f e ad12 u s a r t 2 txd a b d a c b clk i i s c iws c a t b sense14 42 f4 42 f4 pc13 77 vddana a d c i f e ad13 u s a r t 3 rts a b d a c b dac1 i i s c isdo a c i f c acbn1 c a t b sense15 43 g1 43 g1 pc14 78 vddana a d c i f e ad14 u s a r t 3 clk a b d a c b dacn1 i i s c imck a c i f c acbp1 c a t b dis 58 j5 58 j5 pc15 79 lcda t c 1 a0 g l o c in4 lcdca seg0 c a t b sense16 table 3-1. 100-pin gpio controller function multiplexing (sheet 3 of 4) atsam4lc atsam4ls pin gpio supply gpio functions qfn vfbga qfn vfbga abcdefg
21 42023e?sam?07/2013 atsam4l8/l4/l2 59 j6 59 j6 pc16 80 lcda t c 1 b0 g l o c in5 lcdca seg1 c a t b sense17 60 h4 60 h4 pc17 81 lcda t c 1 a1 g l o c in6 lcdca seg2 c a t b sense18 61 k6 61 k6 pc18 82 lcda t c 1 b1 g l o c in7 lcdca seg3 c a t b sense19 62 g4 62 g4 pc19 83 lcda t c 1 a2 g l o c out1 lcdca seg4 c a t b sense20 68 h7 68 h7 pc20 84 lcda t c 1 b2 lcdca seg10 c a t b sense21 69 k8 69 k8 pc21 85 lcda t c 1 clk0 pa r c pcck lcdca seg11 c a t b sense22 70 j8 70 j8 pc22 86 lcda t c 1 clk1 pa r c pcen1 lcdca seg12 c a t b sense23 71 h8 71 h8 pc23 87 lcda t c 1 clk2 pa r c pcen2 lcdca seg13 c a t b dis 79 j9 79 j9 pc24 88 lcdb u s a r t 1 rts e i c extint1 pevc pad evt0 pa r c pcdata0 lcdca seg24 c a t b sense24 80 h9 80 h9 pc25 89 lcdb u s a r t 1 clk e i c extint2 pevc pad evt1 pa r c pcdata1 lcdca seg25 c a t b sense25 81 g9 81 g9 pc26 90 lcdb u s a r t 1 rxd e i c extint3 pevc pad evt2 pa r c pcdata2 s c i f gclk0 lcdca seg26 c a t b sense26 82 f6 82 f6 pc27 91 lcdb u s a r t 1 txd e i c extint4 pevc pad evt3 pa r c pcdata3 s c i f gclk1 lcdca seg27 c a t b sense27 83 g10 83 g10 pc28 92 lcdb u s a r t 3 rxd s p i miso g l o c in4 pa r c pcdata4 s c i f gclk2 lcdca seg28 c a t b sense28 84 f7 84 f7 pc29 93 lcdb u s a r t 3 txd s p i mosi g l o c in5 pa r c pcdata5 s c i f gclk3 lcdca seg29 c a t b sense29 85 f8 85 f8 pc30 94 lcdb u s a r t 3 rts s p i sck g l o c in6 pa r c pcdata6 s c i f gclk in0 lcdca seg30 c a t b sense30 86 f9 86 f9 pc31 95 lcdb u s a r t 3 clk s p i npcs0 g l o c out1 pa r c pcdata7 s c i f gclk in1 lcdca seg31 c a t b sense31 table 3-1. 100-pin gpio controller function multiplexing (sheet 4 of 4) atsam4lc atsam4ls pin gpio supply gpio functions qfn vfbga qfn vfbga abcdefg table 3-2. 64-pin gpio controller function multiplexing (sheet 1 of 3) atsam4lc atsam4ls pin gpio supply gpio functions qfp qfn qfp qfn abcdefg 11pa000vddio 22pa011vddio 3 3 pa02 2 vddin s c i f gclk0 s p i npcs0 c a t b dis 10 10 pa03 3 vddin s p i miso
22 42023e?sam?07/2013 atsam4l8/l4/l2 15 15 pa04 4 vddana a d c i f e ad0 u s a r t 0 clk e i c extint2 g l o c in1 c a t b sense0 16 16 pa05 5 vddana a d c i f e ad1 u s a r t 0 rxd e i c extint3 g l o c in2 adcife trigger c a t b sense1 21 21 pa06 6 vddana d a c c vout u s a r t 0 rts e i c extint1 g l o c in0 a c i f c acan0 c a t b sense2 22 22 pa07 7 vddana a d c i f e ad2 u s a r t 0 txd e i c extint4 g l o c in3 a c i f c acap0 c a t b sense3 26 26 pa08 8 lcda u s a r t 0 rts t c 0 a0 p e v c pad evt0 g l o c out0 lcdca seg23 c a t b sense4 29 29 pa09 9 lcda u s a r t 0 cts t c 0 b0 p e v c pad evt1 p a r c pcdata0 lcdca com3 c a t b sense5 30 30 pa10 10 lcda u s a r t 0 clk t c 0 a1 p e v c pad evt2 p a r c pcdata1 lcdca com2 c a t b sense6 31 31 pa11 11 lcda u s a r t 0 rxd t c 0 b1 p e v c pad evt3 p a r c pcdata2 lcdca com1 c a t b sense7 32 32 pa12 12 lcda u s a r t 0 txd t c 0 a2 p a r c pcdata3 lcdca com0 c a t b dis 40 40 pa13 13 lcda u s a r t 1 rts t c 0 b2 s p i npcs1 p a r c pcdata4 lcdca seg5 c a t b sense8 41 41 pa14 14 lcda u s a r t 1 clk t c 0 clk0 s p i npcs2 p a r c pcdata5 lcdca seg6 c a t b sense9 42 42 pa15 15 lcda u s a r t 1 rxd t c 0 clk1 s p i npcs3 p a r c pcdata6 lcdca seg7 c a t b sense10 43 43 pa16 16 lcda u s a r t 1 txd t c 0 clk2 e i c extint1 p a r c pcdata7 lcdca seg8 c a t b sense11 44 44 pa17 17 lcda u s a r t 2 rts a b d a c b dac0 e i c extint2 p a r c pcck lcdca seg9 c a t b sense12 49 49 pa18 18 lcda u s a r t 2 clk a b d a c b dacn0 e i c extint3 p a r c pcen1 lcdca seg18 c a t b sense13 50 50 pa19 19 lcda u s a r t 2 rxd a b d a c b dac1 e i c extint4 p a r c pcen2 s c i f gclk0 lcdca seg19 c a t b sense14 51 51 pa20 20 lcda u s a r t 2 txd a b d a c b dacn1 e i c extint5 g l o c in0 s c i f gclk1 lcdca seg20 c a t b sense15 55 55 pa21 21 lcdc s p i miso u s a r t 1 cts e i c extint6 g l o c in1 t w i m 2 twd lcdca seg34 c a t b sense16 56 56 pa22 22 lcdc s p i mosi u s a r t 2 cts e i c extint7 g l o c in2 t w i m 2 twck lcdca seg35 c a t b sense17 59 59 pa23 23 lcdc s p i sck t w i m s 0 twd e i c extint8 g l o c in3 s c i f gclk in0 lcdca seg38 c a t b dis 60 60 pa24 24 lcdc s p i npcs0 t w i m s 0 twck g l o c out0 s c i f gclk in1 lcdca seg39 c a t b sense18 62 62 pa25 25 vddio u s b c dm u s a r t 2 rxd c a t b sense19 63 63 pa26 26 vddio u s b c dp u s a r t 2 txd c a t b sense20 table 3-2. 64-pin gpio controller function multiplexing (sheet 2 of 3) atsam4lc atsam4ls pin gpio supply gpio functions qfp qfn qfp qfn abcdefg
23 42023e?sam?07/2013 atsam4l8/l4/l2 33 pa27 27 lcda s p i miso i i s c isck a b d a c b dac0 g l o c in4 u s a r t 3 rts c a t b sense0 34 pa28 28 lcda s p i mosi i i s c isdi a b d a c b dacn0 g l o c in5 u s a r t 3 cts c a t b sense1 35 pa29 29 lcda s p i sck i i s c iws a b d a c b dac1 g l o c in6 u s a r t 3 clk c a t b sense2 38 pa30 30 lcda s p i npcs0 i i s c isdo a b d a c b dacn1 g l o c in7 u s a r t 3 rxd c a t b sense3 39 pa31 31 lcda s p i npcs1 i i s c imck a b d a c b clk g l o c out1 u s a r t 3 txd c a t b dis 11 11 pb00 32 vddin t w i m s 1 twd u s a r t 0 rxd c a t b sense21 12 12 pb01 33 vddin t w i m s 1 twck u s a r t 0 txd e i c extint0 c a t b sense22 13 13 pb02 34 vddana a d c i f e ad3 u s a r t 1 rts a b d a c b dac0 i i s c isck a c i f c acbn0 c a t b sense23 14 14 pb03 35 vddana a d c i f e ad4 u s a r t 1 clk a b d a c b dacn0 i i s c isdi a c i f c acbp0 c a t b dis 19 19 pb04 36 vddana a d c i f e ad5 u s a r t 1 rxd a b d a c b dac1 i i s c isdo d a c c ext trig0 c a t b sense24 20 20 pb05 37 vddana a d c i f e ad6 u s a r t 1 txd a b d a c b dacn1 i i s c imck c a t b sense25 27 27 pb06 38 lcda u s a r t 3 rts g l o c in4 i i s c iws lcdca seg22 c a t b sense26 28 28 pb07 39 lcda u s a r t 3 cts g l o c in5 t c 0 a0 lcdca seg21 c a t b sense27 45 45 pb08 40 lcda u s a r t 3 clk g l o c in6 t c 0 b0 lcdca seg14 c a t b sense28 46 46 pb09 41 lcda u s a r t 3 rxd pevc pa d e vt 2 g l o c in7 t c 0 a1 lcdca seg15 c a t b sense29 47 47 pb10 42 lcda u s a r t 3 txd pevc pa d e vt 3 g l o c out1 t c 0 b1 s c i f gclk0 lcdca seg16 c a t b sense30 48 48 pb11 43 lcda u s a r t 0 cts s p i npcs2 t c 0 a2 s c i f gclk1 lcdca seg17 c a t b sense31 53 53 pb12 44 lcdc u s a r t 0 rts s p i npcs3 p e v c pad evt0 t c 0 b2 s c i f gclk2 lcdca seg32 c a t b dis 54 54 pb13 45 lcdc u s a r t 0 clk s p i npcs1 p e v c pad evt1 t c 0 clk0 s c i f gclk3 lcdca seg33 c a t b sense0 57 57 pb14 46 lcdc u s a r t 0 rxd s p i miso t w i m 3 twd t c 0 clk1 s c i f gclk in0 lcdca seg36 c a t b sense1 58 58 pb15 47 lcdc u s a r t 0 txd s p i mosi t w i m 3 twck t c 0 clk2 s c i f gclk in1 lcdca seg37 c a t b sense2 table 3-2. 64-pin gpio controller function multiplexing (sheet 3 of 3) atsam4lc atsam4ls pin gpio supply gpio functions qfp qfn qfp qfn abcdefg
24 42023e?sam?07/2013 atsam4l8/l4/l2 table 3-3. 64-pin gpio controller function multiplexing for wlcsp package (sheet 1 of 3) atsam4lc atsam4ls pin gpio supply gpio functions wlcsp wlcsp abcdefg g4 g4 pa00 0 vddio g5 g5 pa01 1 vddio f3 f3 pa02 2 vddin s c i f gclk0 s p i npcs0 c a t b dis e2 e2 pa03 3 vddin s p i miso d3 d3 pa04 4 vddana a d c i f e ad0 u s a r t 0 clk e i c extint2 g l o c in1 c a t b sense0 c3 c3 pa05 5 vddana a d c i f e ad1 u s a r t 0 rxd e i c extint3 g l o c in2 a d c i f e trigger c a t b sense1 c4 c4 pa06 6 vddana d a c c vout u s a r t 0 rts e i c extint1 g l o c in0 a c i f c acan0 c a t b sense2 c5 c5 pa07 7 vddana a d c i f e ad2 u s a r t 0 txd e i c extint4 g l o c in3 a c i f c acap0 c a t b sense3 b4 b4 pa08 8 lcda u s a r t 0 rts t c 0 a0 pevc pad evt0 g l o c out0 lcdca seg23 c a t b sense4 a5 a5 pa09 9 lcda u s a r t 0 cts t c 0 b0 pevc pad evt1 pa r c pcdata0 lcdca com3 c a t b sense5 b6 b6 pa10 10 lcda u s a r t 0 clk t c 0 a1 pevc pad evt2 pa r c pcdata1 lcdca com2 c a t b sense6 b7 b7 pa11 11 lcda u s a r t 0 rxd t c 0 b1 pevc pad evt3 pa r c pcdata2 lcdca com1 c a t b sense7 a8 a8 pa12 12 lcda u s a r t 0 txd t c 0 a2 pa r c pcdata3 lcdca com0 c a t b dis c7 c7 pa13 13 lcda u s a r t 1 rts t c 0 b2 s p i npcs1 pa r c pcdata4 lcdca seg5 c a t b sense8 d7 d7 pa14 14 lcda u s a r t 1 clk t c 0 clk0 s p i npcs2 pa r c pcdata5 lcdca seg6 c a t b sense9 e7 e7 pa15 15 lcda u s a r t 1 rxd t c 0 clk1 s p i npcs3 pa r c pcdata6 lcdca seg7 c a t b sense10 f7 f7 pa16 16 lcda u s a r t 1 txd t c 0 clk2 e i c extint1 pa r c pcdata7 lcdca seg8 c a t b sense11 g8 g8 pa17 17 lcda u s a r t 2 rts a b d a c b dac0 e i c extint2 pa r c pcck lcdca seg9 c a t b sense12 g7 g7 pa18 18 lcda u s a r t 2 clk a b d a c b dacn0 e i c extint3 pa r c pcen1 lcdca seg18 c a t b sense13 g6 g6 pa19 19 lcda u s a r t 2 rxd a b d a c b dac1 e i c extint4 pa r c pcen2 s c i f gclk0 lcdca seg19 c a t b sense14 h7 h7 pa20 20 lcda u s a r t 2 txd a b d a c b dacn1 e i c extint5 g l o c in0 s c i f gclk1 lcdca seg20 c a t b sense15 h5 h5 pa21 21 lcdc s p i miso u s a r t 1 cts e i c extint6 g l o c in1 t w i m 2 twd lcdca seg34 c a t b sense16 f5 f5 pa22 22 lcdc s p i mosi u s a r t 2 cts e i c extint7 g l o c in2 t w i m 2 twck lcdca seg35 c a t b sense17
25 42023e?sam?07/2013 atsam4l8/l4/l2 h3 h3 pa23 23 lcdc s p i sck t w i m s 0 twd e i c extint8 g l o c in3 s c i f gclk in0 lcdca seg38 c a t b dis g3 g3 pa24 24 lcdc s p i npcs0 t w i m s 0 twck g l o c out0 s c i f gclk in1 lcdca seg39 c a t b sense18 h2 h2 pa25 25 vddio u s b c dm u s a r t 2 rxd c a t b sense19 g2 g2 pa26 26 vddio u s b c dp u s a r t 2 txd c a t b sense20 a7 pa27 27 lcda s p i miso i i s c isck a b d a c b dac0 g l o c in4 u s a r t 3 rts c a t b sense0 a6 pa28 28 lcda s p i mosi i i s c isdi a b d a c b dacn0 g l o c in5 u s a r t 3 cts c a t b sense1 b8 pa29 29 lcda s p i sck i i s c iws a b d a c b dac1 g l o c in6 u s a r t 3 clk c a t b sense2 e8 pa30 30 lcda s p i npcs0 i i s c isdo a b d a c b dacn1 g l o c in7 u s a r t 3 rxd c a t b sense3 f8 pa31 31 lcda s p i npcs1 i i s c imck a b d a c b clk g l o c out1 u s a r t 3 txd c a t b dis d2 d2 pb00 32 vddin t w i m s 1 twd u s a r t 0 rxd c a t b sense21 c2 c2 pb01 33 vddin t w i m s 1 twck u s a r t 0 txd e i c extint0 c a t b sense22 e3 e3 pb02 34 vddana a d c i f e ad3 u s a r t 1 rts a b d a c b dac0 i i s c isck a c i f c acbn0 c a t b sense23 b1 b1 pb03 35 vddana a d c i f e ad4 u s a r t 1 clk a b d a c b dacn0 i i s c isdi a c i f c acbp0 c a t b dis a1 a1 pb04 36 vddana a d c i f e ad5 u s a r t 1 rxd a b d a c b dac1 i i s c isdo d a c c ext trig0 c a t b sense24 d4 d4 pb05 37 vddana a d c i f e ad6 u s a r t 1 txd a b d a c b dacn1 i i s c imck c a t b sense25 b5 b5 pb06 38 lcda u s a r t 3 rts g l o c in4 i i s c iws lcdca seg22 c a t b sense26 c6 c6 pb07 39 lcda u s a r t 3 cts g l o c in5 t c 0 a0 lcdca seg21 c a t b sense27 d6 d6 pb08 40 lcda u s a r t 3 clk g l o c in6 t c 0 b0 lcdca seg14 c a t b sense28 e6 e6 pb09 41 lcda u s a r t 3 rxd p e v c pad evt2 g l o c in7 t c 0 a1 lcdca seg15 c a t b sense29 f6 f6 pb10 42 lcda u s a r t 3 txd p e v c pad evt3 g l o c out1 t c 0 b1 s c i f gclk0 lcdca seg16 c a t b sense30 h8 h8 pb11 43 lcda u s a r t 0 cts s p i npcs2 t c 0 a2 s c i f gclk1 lcdca seg17 c a t b sense31 d5 d5 pb12 44 lcdc u s a r t 0 rts s p i npcs3 pevc pad evt0 t c 0 b2 s c i f gclk2 lcdca seg32 c a t b dis table 3-3. 64-pin gpio controller function multiplexing for wlcsp package (sheet 2 of 3) atsam4lc atsam4ls pin gpio supply gpio functions wlcsp wlcsp abcdefg
26 42023e?sam?07/2013 atsam4l8/l4/l2 e5 e5 pb13 45 lcdc u s a r t 0 clk s p i npcs1 pevc pad evt1 t c 0 clk0 s c i f gclk3 lcdca seg33 c a t b sense0 f4 f4 pb14 46 lcdc u s a r t 0 rxd s p i miso t w i m 3 twd t c 0 clk1 s c i f gclk in0 lcdca seg36 c a t b sense1 h4 h4 pb15 47 lcdc u s a r t 0 txd s p i mosi t w i m 3 twck t c 0 clk2 s c i f gclk in1 lcdca seg37 c a t b sense2 table 3-3. 64-pin gpio controller function multiplexing for wlcsp package (sheet 3 of 3) atsam4lc atsam4ls pin gpio supply gpio functions wlcsp wlcsp abcdefg
27 42023e?sam?07/2013 atsam4l8/l4/l2 table 3-4. 48-pin gpio controller function multiplexing (sheet 1 of 2) atsam4lc atsam4ls pin gpio supply gpio functions abcdefg 1 1 pa00 0 vddio 2 2 pa01 1 vddio 3 3 pa02 2 vddin s c i f gclk0 s p i npcs0 c a t b dis 10 10 pa03 3 vddin s p i miso 11 11 pa04 4 vddana a d c i f e ad0 u s a r t 0 clk e i c extint2 g l o c in1 c a t b sense0 12 12 pa05 5 vddana a d c i f e ad1 u s a r t 0 rxd e i c extint3 g l o c in2 a d c i f e trigger c a t b sense1 15 15 pa06 6 vddana d a c c vout u s a r t 0 rts e i c extint1 g l o c in0 a c i f c acan0 c a t b sense2 16 16 pa07 7 vddana a d c i f e ad2 u s a r t 0 txd e i c extint4 g l o c in3 a c i f c acap0 c a t b sense3 20 20 pa08 8 lcda u s a r t 0 rts t c 0 a0 pevc pa d e vt 0 g l o c out0 l c d c a seg23 c a t b sense4 21 21 pa09 9 lcda u s a r t 0 cts t c 0 b0 pevc pa d e vt 1 parc pcdata0 l c d c a com3 c a t b sense5 22 22 pa10 10 lcda u s a r t 0 clk t c 0 a1 pevc pa d e vt 2 parc pcdata1 l c d c a com2 c a t b sense6 23 23 pa11 11 lcda u s a r t 0 rxd t c 0 b1 pevc pa d e vt 3 parc pcdata2 l c d c a com1 c a t b sense7 24 24 pa12 12 lcda u s a r t 0 txd t c 0 a2 parc pcdata3 l c d c a com0 c a t b dis 32 32 pa13 13 lcda u s a r t 1 rts t c 0 b2 s p i npcs1 parc pcdata4 l c d c a seg5 c a t b sense8 33 33 pa14 14 lcda u s a r t 1 clk t c 0 clk0 s p i npcs2 parc pcdata5 l c d c a seg6 c a t b sense9 34 34 pa15 15 lcda u s a r t 1 rxd t c 0 clk1 s p i npcs3 parc pcdata6 l c d c a seg7 c a t b sense10 35 35 pa16 16 lcda u s a r t 1 txd t c 0 clk2 e i c extint1 parc pcdata7 l c d c a seg8 c a t b sense11 36 36 pa17 17 lcda u s a r t 2 rts a b d a c b dac0 e i c extint2 parc pcck l c d c a seg9 c a t b sense12 37 37 pa18 18 lcda u s a r t 2 clk a b d a c b dacn0 e i c extint3 parc pcen1 l c d c a seg18 c a t b sense13 38 38 pa19 19 lcda u s a r t 2 rxd a b d a c b dac1 e i c extint4 parc pcen2 s c i f gclk0 l c d c a seg19 c a t b sense14 39 39 pa20 20 lcda u s a r t 2 txd a b d a c b dacn1 e i c extint5 g l o c in0 s c i f gclk1 l c d c a seg20 c a t b sense15 41 41 pa21 21 lcdc s p i miso u s a r t 1 cts e i c extint6 g l o c in1 t w i m 2 twd l c d c a seg34 c a t b sense16 42 42 pa22 22 lcdc s p i mosi u s a r t 2 cts e i c extint7 g l o c in2 t w i m 2 twck l c d c a seg35 c a t b sense17 43 43 pa23 23 lcdc s p i sck t w i m s 0 twd e i c extint8 g l o c in3 s c i f gclk in0 l c d c a seg38 c a t b dis
28 42023e?sam?07/2013 atsam4l8/l4/l2 3.2.2 peripheral functions each gpio line can be assigned to one of several peripheral functions. the following table describes how the various peripheral functions are selected. the last listed function has priority in case multiple functions are enabled on the same pin. 3.2.3 jtag port connections if the jtag is enabled, the jtag will take control over a number of pins, irrespectively of the i/o controller configuration. 44 44 pa24 24 lcdc s p i npcs0 t w i m s 0 twck g l o c out0 s c i f gclk in1 l c d c a seg39 c a t b sense18 46 46 pa25 25 vddio u s b c dm u s a r t 2 rxd c a t b sense19 47 47 pa26 26 vddio u s b c dp u s a r t 2 txd c a t b sense20 25 pa27 27 lcda s p i miso i i s c isck a b d a c b dac0 g l o c in4 u s a r t 3 rts c a t b sense0 26 pa28 28 lcda s p i mosi i i s c isdi a b d a c b dacn0 g l o c in5 u s a r t 3 cts c a t b sense1 27 pa29 29 lcda s p i sck i i s c iws a b d a c b dac1 g l o c in6 u s a r t 3 clk c a t b sense2 30 pa30 30 lcda s p i npcs0 i i s c isdo a b d a c b dacn1 g l o c in7 u s a r t 3 rxd c a t b sense3 31 pa31 31 lcda s p i npcs1 i i s c imck a b d a c b clk g l o c out1 u s a r t 3 txd c a t b dis table 3-4. 48-pin gpio controller function multiplexing (sheet 2 of 2) atsam4lc atsam4ls pin gpio supply gpio functions abcdefg table 3-5. peripheral functions function description gpio controller function multiplexing gpio and gpio peripheral selection a to h jtag port connections jtag debug port oscillators osc0 table 3-6. jtag pinout 48-pin packages 64-pin qfp/qfn 64-pin wlscp 100-pin qfn 100-ball vfbga pin name jtag pin 10 10 e2 19 b3 pa03 tms 43 59 h3 95 d6 pa23 tdo 44 60 h2 96 d10 pa24 tdi 99f218b4tcktck
29 42023e?sam?07/2013 atsam4l8/l4/l2 3.2.4 itm trace connections if the itm trace is enabled, the itm will take cont rol over the pin pa23, irrespectively of the i/o controller configuration. the serial wire trace signal is available on pin pa23 3.2.5 oscillator pinout the oscillators are not mapped to the normal gp io functions and their muxings are controlled by registers in the system control interface (scif) or backup system control interface (bscif). refer to the section 13. ?system control interface (scif)? on page 202 and section 12. ?backup system control interface (bscif)? on page 160 for more information about this. table 3-7. oscillator pinout 48-pin packages 64-pin qfn/qfp 64-pin wlcsp 100-pin packages 100-ball vfbga pin name oscillator pin 11g45b9 pa00 xin0 13 17 b2 26 b2 xin32 xin32 2 2 g5 6 b8 pa01 xout0 14 18 b3 27 c2 xout32 xout32
30 42023e?sam?07/2013 atsam4l8/l4/l2 3.3 signals description the following table gives details on signal names classified by peripheral. table 3-8. signal descriptions list (sheet 1 of 4) signal name function type active level comments audio bitstream dac - abdacb clk d/a clock output output dac1 - dac0 d/a bitstream outputs output dacn1 - dacn0 d/a inverted bitstream outputs output analog comparator interface - acifc acan1 - acan0 analog comparator a negative references analog acap1 - acap0 analog comparator a positive references analog acbn1 - acbn0 analog comparator b negative references analog acbp1 - acbp0 analog comparator b positive references analog adc controller interface - adcife ad14 - ad0 analog inputs analog advrefp positive voltage reference analog trigger external trigger input backup system control interface - bscif xin32 32 khz crystal oscillator input analog/ digital xout32 32 khz crystal oscillator output analog capacitive touch module b - catb dis capacitive discharge line output sense31 - sense0 capacitive sense lines i/o dac controller - dacc dac external trigger dac external trigger input dac voltage output dac voltage output analog enhanced debug port for arm products - edp tck/swclk jtag / sw debug clock input tdi jtag debug data in input tdo/traceswo jtag debug data out / sw trace out output tms/swdio jtag debug mode select / sw data i/o external interrup t controller - eic extint8 - extint0 extern al interrupts input glue logic controller - gloc in7 - in0 lookup tables inputs input out1 - out0 lookup tables outputs output
31 42023e?sam?07/2013 atsam4l8/l4/l2 inter-ic sound (i2s) controller - iisc imck i2s master clock output isck i2s serial clock i/o isdi i2s serial data in input isdo i2s serial data out output iws i2s word select i/o lcd controller - lcdca biasl bias voltage (1/3 vlcd) analog biash bias voltage (2/3 vlcd) analog caph high voltage end of flying capacitor analog capl low voltage end of flying capacitor analog com3 - com0 common terminals analog seg39 - seg0 segment terminals analog vlcd bias voltage analog parallel capture - parc pcck clock input pcdata7 - pcdata0 data lines input pcen1 data enable 1 input pcen2 data enable 2 input peripheral event controller - pevc pad_evt3 - pad_evt0 event inputs input power manager - pm reset_n reset input low system control interface - scif gclk3 - gclk0 generic clock outputs output gclk_in1 - gclk_in0 generic clock inputs input xin0 crystal 0 input analog/ digital xout0 crystal 0 output analog serial peripheral interface - spi miso master in slave out i/o mosi master out slave in i/o npcs3 - npcs0 spi peripheral chip selects i/o low sck clock i/o timer/counter - tc0, tc1 table 3-8. signal descriptions list (sheet 2 of 4) signal name function type active level comments
32 42023e?sam?07/2013 atsam4l8/l4/l2 a0 channel 0 line a i/o a1 channel 1 line a i/o a2 channel 2 line a i/o b0 channel 0 line b i/o b1 channel 1 line b i/o b2 channel 2 line b i/o clk0 channel 0 external clock input input clk1 channel 1 external clock input input clk2 channel 2 external clock input input two-wire interface - twims0, twims1, twim2, twim3 twck two-wire serial clock i/o twd two-wire serial data i/o universal synchronous asynchronous receiver transmitter - usart0, usart1, usart2, usart3 clk clock i/o cts clear to send input low rts request to send output low rxd receive data input txd transmit data output usb 2.0 interface - usbc dm usb full speed interface data - i/o dp usb full speed interface data + i/o power gnd ground ground gndana analog ground ground vddana analog power supply power input 1.68v to 3.6v vddcore core power supply power input 1.68v to 1.98v vddin voltage regulator input power input 1.68v to 3.6v vddio i/o pads power supply power input 1.68v to 3.6v. vddio must always be equal to or lower than vddin. vddout voltage regulator output power output 1.08v to 1.98v general purpose i/o table 3-8. signal descriptions list (sheet 3 of 4) signal name function type active level comments
33 42023e?sam?07/2013 atsam4l8/l4/l2 note: 1. see ?power and startup considerations? section. 3.4 i/o line considerations 3.4.1 sw/jtag pins the jtag pins switch to the jtag functions if a rising edge is detected on tck low after the reset_n pin has been released. the tms, and tdi pins have pull-up resistors when used as jtag pins. the tck pin always has pull-up enabl ed during reset. the jtag pins can be used as gpio pins and multiplexed with peripherals when the jtag is disabled. refer to section 3.2.3 ?jtag port connections? on page 28 for the jtag port connections. for more details, refer to section 8.7 ?enhanced debug port (edp)? on page 66 . 3.4.2 reset_n pin the reset_n pin is a schmitt input and integrates a permanent pull-up resistor to vddin. as the product integrates a power-on reset detector, the reset_n pin can be left unconnected in case no reset from the system nee ds to be applied to the product. 3.4.3 twi pins when these pins are used for twi, the pins are open-drain outputs with slew-rate limitation and- inputs with inputs with spike-filtering. when used as gpio-pins or used for other peripherals, the pins have the same charac teristics as gpio pins. 3.4.4 gpio pins all the i/o lines integrate a pull-up/pull-down resistor and slew rate controller . programming these features is performed independently for eac h i/o line through the gpio controllers. after reset, i/o lines default as inputs with pull-up and pull-down resistors disabled and slew rate enabled. 3.4.5 high-drive pins the six pins pa02, pb00, pb01, pc04, pc05 a nd pc06 have high-drive output capabilities. refer to section 42.6.2 ?high-drive i/o pin : pa02, pc04, pc05, pc06? on page 1136 for electri- cal characteristics. 3.4.6 usb pins when these pins are used for usb, the pins ar e behaving according to the usb specification. when used as gpio pins or used for other peripherals, the pins have the same behavior as other normal i/o pins, but the characteristics are different. refer to section 42.6.3 ?usb i/o pin : pa25, pa26? on page 1137 for electrical characteristics. these pins are compliant to usb standard only when vddio power supply is 3.3 v nominal. pa31 - pa00 parallel i/o controller i/o port a i/o pb15 - pb00 parallel i/o controller i/o port b i/o pc31 - pc00 parallel i/o controller i/o port c i/o table 3-8. signal descriptions list (sheet 4 of 4) signal name function type active level comments
34 42023e?sam?07/2013 atsam4l8/l4/l2 3.4.7 adc input pins these pins are regular i/o pins powered from the vddana.
35 42023e?sam?07/2013 atsam4l8/l4/l2 4. cortex-m4 processor and core peripherals 4.1 cortex-m4 the cortex-m4 processor is a high performanc e 32-bit processor designed for the microcon- troller market. it offers significant benefits to developers, including: ? outstanding processing performance combined with fast interrupt handling ? enhanced system debug with extensiv e breakpoint and trace capabilities ? efficient processor core , system and memories ? ultra-low power consumption with integrated sleep modes ? platform security robustness, with inte grated memory protection unit (mpu). the cortex-m4 processor is built on a high-performance processor core, with a 3-stage pipeline harvard architecture, making it ideal for demanding embedded applications. the processor delivers exceptional power efficiency through an efficient instruction set and extensively opti- mized design, providing high-end processing hardware including a range of single-cycle and simd multiplication and multiply -with-accumulate capabilities, sa turating arithmetic and dedi- cated hardware division. to facilitate the design of cost-sensitive device s, the cortex-m4 processor implements tightly- coupled system components that reduce processo r area while significantly improving interrupt handling and system debug capabilitie s. the cortex-m4 processor implements a version of the thumb ? instruction set based on thumb-2 technology, ensuring high code density and reduced program memory requirements. the cortex-m4 instruction set provides the exceptional perfor- mance expected of a modern 32-bit architecture, with the high code density of 8-bit and 16-bit microcontrollers. the cortex-m4 processor closely integrates a configurable nested vectored interrupt controller (nvic), to deliver industry-leading interrupt performance. the nvic includes a non-maskable interrupt (nmi), and provides up to 80 interrupt priority levels. the tight integration of the proces- nvic debug access port memory protection unit serial wire viewer bus matrix code interface sram and peripheral interface data watchpoints flash patch cortex-m4 processor processor core
36 42023e?sam?07/2013 atsam4l8/l4/l2 sor core and nvic provides fast execution of interrupt service routines (isrs), dramatically reducing the interrupt latency. this is achiev ed through the hardware stacking of registers, and the ability to suspend load-multiple and store-multiple operations. interrupt handlers do not require wrapping in assembler code, removing any code overhead from the isrs. a tail-chain optimization also significantly reduces the overhead when switching from one isr to another. to optimize low-power designs, the nvic integrates with the sleep modes , that include a deep sleep function enabling the entire device to be rapidly powered down while still retaining pro- gram state. 4.2 system level interface the cortex-m4 processor provides multiple interfaces using amba ? technology to provide high speed, low latency memory accesses. it su pports unaligned data accesses and implements atomic bit manipulation that enables faster pe ripheral controls, system spinlocks and thread-safe boolean data handling. the cortex-m4 processor has an memory protection unit (mpu) that provides fine grain memory control, enabling applications to utilize multiple privilege levels, separating and protecting code, data and stack on a task-by-task basis. such requirements are becoming critical in many embedded applications such as automotive. 4.3 integrated configurable debug the cortex-m4 processor implements a complete hardware debug solution. this provides high system visibility of the processor and memory through ei ther a traditional jt ag port or a 2-pin serial wire debug (swd) port that is ideal for microcon trollers and other small package devices. for system trace the proc essor integrates an instrumentation trace macrocell (itm) alongside data watchpoints an d a profiling unit. to enable simple and cost-effective pr ofiling of the system events these generate, a serial wire viewer (swv) can export a stream of software-generated messages, data trace, and profiling informati on through a single pin. the flash patch and breakpoint unit (fpb) provides 8 hardware breakpoint comparators that debuggers can use. the comparators in the fpb also provide remap functions of up to 8 words in the program code in the code memory region. this enables applications stored on a non- erasable, rom-based microcontroller to be patched if a small programmable memory, for exam- ple flash, is available in the device. during initia lization, the application in rom detects, from the programmable memory, whether a patch is required. if a patch is required, the application pro- grams the fpb to remap a number of addresses. when those addresses are accessed, the accesses are redirected to a remap table specified in the fpb configuration, which means the program in the non-modifiable rom can be patched. a specific peripheral debug (pdbg) register is implemented in the private peripheral bus address map. this register allows the user to configure the behavior of some modules in debug mode.
37 42023e?sam?07/2013 atsam4l8/l4/l2 4.4 cortex-m4 processor features and benefits summary ? tight integration of system peripheral s reduces area and development costs ? thumb instruction set combines high co de density with 32-bit performance ? code-patch ability for rom system updates ? power control optimization of system components ? integrated sleep modes for low power consumption ? fast code execution permits slower proc essor clock or increases sleep mode time ? hardware division and fast digital-signal-processing orie ntated multiply accumulate ? saturating arithmetic for signal processing ? deterministic, high-performance interrupt handling for time-critical applications ? memory protection unit (mpu) for safety-cr itical applications ? extensive debug and trace capabilities: ? serial wire debug and serial wire trace reduce the number of pins required for debugging, tracing, and code profiling. 4.5 cortex-m4 core peripherals these are: nested vectored interrupt controller the nvic is an embedded interrupt controller that supports low latency interrupt processing. system control block the system control block (scb) is the programmers model interface to the processor. it pro- vides system implementation info rmation and system control, in cluding configuration, control, and reporting of system exceptions. system timer the system timer, systick, is a 24 -bit count-down timer. use this as a real time operating sys- tem (rtos) tick timer or as a simple counter. memory protection unit the memory protection unit (mpu) improves system reliability by defining the memory attributes for different memory regions. it provides up to eight different regions, and an optional predefined background region. the complete cortex-m4 user guide can be found on the arm web site: http://infocenter.arm.com/help/topic/com.arm.doc.dui0553a/dui0553a_cortex_m4_dgug.pdf
38 42023e?sam?07/2013 atsam4l8/l4/l2 4.6 cortex-m4 implementations options this table provides the specific configurat ion options implemented in the sam4l series table 4-1. cortex-m4 implementation options 4.7 cortex-m4 interrupts map the table below shows how the interrupt re quest signals are connected to the nvic. option implementation inclusion of mpu yes inclusion of fpu no number of interrupts 80 number of priority bits 4 inclusion of the wic no embedded trace macrocell no sleep mode instruction only wfi supported endianness little endian bit-banding no systick timer yes register reset values no table 4-2. interrupt request signal map (sheet 1 of 3) line module signal 0 flash controller hflashc 1 peripheral dma controller pdca 0 2 peripheral dma controller pdca 1 3 peripheral dma controller pdca 2 4 peripheral dma controller pdca 3 5 peripheral dma controller pdca 4 6 peripheral dma controller pdca 5 7 peripheral dma controller pdca 6 8 peripheral dma controller pdca 7 9 peripheral dma controller pdca 8 10 peripheral dma controller pdca 9 11 peripheral dma controller pdca 10
39 42023e?sam?07/2013 atsam4l8/l4/l2 12 peripheral dma controller pdca 11 13 peripheral dma controller pdca 12 14 peripheral dma controller pdca 13 15 peripheral dma controller pdca 14 16 peripheral dma controller pdca 15 17 crc calculation unit crccu 18 usb 2.0 interface usbc 19 peripheral event controller pevc tr 20 peripheral event controller pevc ov 21 advanced encryption standard aesa 22 power manager pm 23 system control interface scif 24 frequency meter freqm 25 general-purpose input/ou tput controller gpio 0 26 general-purpose input/ou tput controller gpio 1 27 general-purpose input/ou tput controller gpio 2 28 general-purpose input/ou tput controller gpio 3 29 general-purpose input/ou tput controller gpio 4 30 general-purpose input/ou tput controller gpio 5 31 general-purpose input/ou tput controller gpio 6 32 general-purpose input/ou tput controller gpio 7 33 general-purpose input/ou tput controller gpio 8 34 general-purpose input/ou tput controller gpio 9 35 general-purpose input/ou tput controller gpio 10 36 general-purpose input/ou tput controller gpio 11 37 backup power manager bpm 38 backup system control interface bscif 39 asynchronous timer ast alarm 40 asynchronous timer ast per 41 asynchronous timer ast ovf 42 asynchronous timer ast ready 43 asynchronous timer ast clkready 44 watchdog timer wdt 45 external interrupt controller eic 1 46 external interrupt controller eic 2 47 external interrupt controller eic 3 table 4-2. interrupt request signal map (sheet 2 of 3) line module signal
40 42023e?sam?07/2013 atsam4l8/l4/l2 48 external interrupt controller eic 4 49 external interrupt controller eic 5 50 external interrupt controller eic 6 51 external interrupt controller eic 7 52 external interrupt controller eic 8 53 inter-ic sound (i2s) controller iisc 54 serial peripheral interface spi 55 timer/counter tc00 56 timer/counter tc01 57 timer/counter tc02 58 timer/counter tc10 59 timer/counter tc11 60 timer/counter tc12 61 two-wire master interface twim0 62 two-wire slave interface twis0 63 two-wire master interface twim1 64 two-wire slave interface twis1 65 universal synchronous asynchronous receiver transmitter usart0 66 universal synchronous asynchronous receiver transmitter usart1 67 universal synchronous asynchronous receiver transmitter usart2 68 universal synchronous asynchronous receiver transmitter usart3 69 adc controller interface adcife 70 dac controller dacc 71 analog comparator interface acifc 72 audio bitstream dac abdacb 73 true random number generator trng 74 parallel capture parc 75 capacitive touch module b catb 77 two-wire master interface twim2 78 two-wire master interface twim3 79 lcd controller a lcdca table 4-2. interrupt request signal map (sheet 3 of 3) line module signal
41 42023e?sam?07/2013 atsam4l8/l4/l2 4.8 peripheral debug the pdbg register controls the behavior of asynchronous peripherals when the device is in debug mode.when the corres ponding bit is set, that peripheral will be in a frozenstate in debug mode. 4.8.1 peripheral debug name: pdbg access type: read/write address: 0xe0042000 reset value: 0x00000000 ? wdt: watchdog pdbg bit wdt = 0: the wdt counter is not frozen during debug operation. wdt = 1: the wdt counter is frozen dur ing debug operation when core is halted ? ast: asynchronous timer pdbg bit ast = 0: the ast prescaler and counter is not frozen during debug operation. ast = 1: the ast prescaler and counter is froz en during debug operation when core is halted. ? pevc: pevc pdbg bit pevc= 0: pevc is not frozen during debug operation. pevc= 1: pevc is frozen during debug operation when core is halted. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------- 76543210 - - - - - pevc ast wdt
42 42023e?sam?07/2013 atsam4l8/l4/l2 5. power and startup considerations 5.1 power domain overview figure 5-1. atsam4ls power domain diagram asynchronous timer external interrupt controller watchdog timer backup power manager backup system control interface osc32k rc32k backup registers system control interface power manager frequency meter gpio por33 bod33 bod18 startup logic por18 pll dfll rcsys peripheral bridge c peripherals peripheral bridge a ahb peripherals peripheral bridge b bus matrix cortex m4 cpu flash pdca ram peripheral bridge d core domain vddana domain backup domain vddana gndana mposc ad0-ad14 advref ac0a-ac3a ac0b-ac3b xin32 xout32 extint0-extint8 usbc analog comparators adc rcfast rc80m vddin gnd vddout vddcore dual output trimmable voltage regulator buck/ldon (pa02) dac dacout vddio gnd vddio domain gpios usb pads
43 42023e?sam?07/2013 atsam4l8/l4/l2 figure 5-2. atsam4lc power domain diagram asynchronous timer external interrupt controller watchdog timer backup power manager backup system control interface osc32k rc32k backup registers system control interface power manager frequency meter gpio por33 bod33 bod18 startup logic por18 pll dfll rcsys peripheral bridge c peripherals peripheral bridge a ahb peripherals peripheral bridge b bus matrix cortex m4 cpu flash pdca ram peripheral bridge d core domain vddana domain backup domain vddana gndana mposc ad0-ad14 advref ac0a-ac3a ac0b-ac3b xin32 xout32 extint0-extint8 usbc analog comparators adc rcfast rc80m vddin gnd vddout vddcore dual output trimmable voltage regulator buck/ldon (pa02) dac dacout vlcdin gnd lcda domain gpios lcd vpump caph capl biash biasl vlcd vddio lcdb domain gpios vddio gpios lcdc domain vddio gnd vddio domain gpios usb pads
44 42023e?sam?07/2013 atsam4l8/l4/l2 5.2 power supplies the atsam4l8/l4/l2 has several types of power supply pins: ? vddio: powers i/o lines, the general purpose oscillator (osc), the 80mhz integrated rc oscillator (rc80m) . voltage is 1.68v to 3.6v. ? vlcdin: (atsam4lc only) powers the lcd voltage pump. voltage is 1.68v to 3.6v. ? vddin: powers the internal voltage regulator. voltage is 1.68v to 3.6v. ? vddana: powers the adc, the dac, the analog comparators, the 32khz oscillator (osc32k), the 32khz integrated rc oscillator (rc32k)and the brown-out detectors (bod18 and bod33). voltage is 1.68v to 3.6v nominal. ? vddcore: powers the core, memories, peripherals, the pll, the dfll, the 4mhz integrated rc oscillator (rcf ast) and the 115khz integrat ed rc oscillator (rcsys). ? vddout is the output voltage of the regulator and must be connected with or without an inductor to vddcore. the ground pins gnd are common to vddcore, vddio, and vddin. the ground pin for vddana is gndana. for decoupling recommendations for the different power supplies, refer to the schematic document. 5.2.1 voltage regulator an embedded voltage regulator supplies all the digital logic in the core and the backup power domains. the regulator has two functionnal mode depending of buck/ldon (pa02) pin value. when this pin is low, the regulator is in linear mode and vddout must be connected to vddcore exter- nally. when this pin is high, it behaves as a s witching regulator and an inductor must be placed between vddout and vddcore. the value of this pin is sampled during the power-up phase when the power on reset 33 reaches v pot+ ( section 42.9 ?analog characteristics? on page 1150 ) its output voltages in the core domain (v core ) and in the backup domain (v bkup ) are always equal except in backup mode where the core domain is not powered (v core =0). the backup domain is always powered. the voltage regulator features three different modes: ? normal mode: the regulator is configured as linear or switching regulator. it can support all different run and sleep modes. ? low power (lp) mode: the regulator consumes little static current. it can be used in wait modes. ? ultra low power (ulp) mode: the regulator consumes very little static current . it is dedicated to retention and backup modes. in backup mode, the regulator only supplies the backup domain.
45 42023e?sam?07/2013 atsam4l8/l4/l2 5.2.2 typical powering schematics the atsam4l8/l4/l2 supports the single supply mode from 1.68v to 3.6v. depending on the input voltage range and on the final application frequency, it is recommended to use the follow- ing table in order to choose the most efficient power strategy figure 5-3. efficient power strategy: n/a possible but not efficient 1.68v 1.80v 2.00v 2.30v 3.60v optimal power efficiency linear mode (buck/ldon (pa02) =0) optimal power efficiency possible but not efficient switching mode (buck/ldon (pa02) =1) f cpumax 12mhz powerscaling ps1 (1) up to 36mhz in ps0 up to 12mhz in ps1 up to 48mhz in ps2 all vddin voltage typical power consumption in run mode 100a/mhz @ f cpu =12mhz(ps1) @ v vddin =3.3v 180a/mhz @ f cpu =48mhz(ps2) @ v vddin =3.3v 212a/mhz @ f cpu =12mhz(ps1) 306a/mhz @ f cpu = 48mhz(ps2) typical power consumption in ret mode 1.5a note 1. the sam4l boots in ps0 on rcsys(115khz), then the application must switch to ps1 before running on higher frequency (<12mhz)
46 42023e?sam?07/2013 atsam4l8/l4/l2 the internal regulator is connected to the vddin pin and its outpu t vddout feeds vddcore in linear mode or through an inductor in switching mode. figure 5-4 shows the power schematics to be used. all i/o lines will be powered by the same power (v vddin =v vddio =v vddana ). figure 5-4. single supply mode 5.2.3 lcd power modes 5.2.3.1 principle lcd lines is powered using the device internal voltage sources provided by the lcdpwr block. when enabled, the lcdpwr blocks will generate the vl cd, biasl, biash voltages. lcd pads are splitted into three clusters that can be powered independently namely clusters a, b and c. a cluster can either be in gpio mode or in lcd mode. when a cluster is in gpio mode, its vddio pin must be powered externally. none of its gpio pin can be used as a lcd line when a cluster is in lcd mode, each clusters vddio pin can be either forced externally (1.8- 3.6v) or unconnected (nc). gpios in a cluster are not available when it is in lcd mode. a clus- ter is set in lcd mode by the lcdca controller when it is enabled depending on the number of segments configured. the lcdpwr block is po wered by the vlcdin pin inside cluster a when lcd feature is not used, vlcdin must be always powered (1.8-3.6v). vlcd, caph, capl, biash, biasl can be le ft unconnected in this case vddin vddio vddana vddcore regulator adc, dac, ac0/1, rc32k, osc32k, bod18, bod33 rc80m, osc, core domain: cpu, peripherals, ram, flash, rcsys, pll, dfll, rcfast backup domain: ast, wdt, eic, bpm, bscif main supply (1.68v-3.6v) vddout buck/ldon (pa02) vlcdin lcd vpump
47 42023e?sam?07/2013 atsam4l8/l4/l2 figure 5-5. lcd clusters in the device 5.2.3.2 internal lcd voltage in this mode the lcd voltages are internally generated. depending of the number of segments required by the application, lcdb and ldcc cl usters vddio pin must be unconnected (nc) or 1 2 3 4 5 6 gnd 7 vddio 8 9 10 11 12 13 14 gnd 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 gndana 33 34 vddana 35 36 37 38 39 40 41 42 43 44 45 46 47 com2 48 com1 49 com0 50 seg17 75 seg16 74 seg15 73 seg14 72 seg13 71 seg12 70 seg11 69 seg10 68 seg9 67 seg8 66 seg7 65 seg6 64 seg5 63 seg4 62 seg3 61 seg2 60 seg1 59 seg0 58 vlcdin 57 gnd 56 biasl 55 biash 54 vlcd 53 capl 52 caph 51 seg18 76 seg19 77 seg20 78 seg24 79 seg25 80 seg26 81 seg27 82 seg28 83 seg29 84 seg30 85 seg31 86 vddio 87 vddio 88 seg32 89 seg33 90 seg34 91 seg35 92 seg36 93 seg37 94 seg38 95 seg39 96 97 98 99 gnd 100 vddout vddin vddcore com3 seg21 seg22 seg23 1 2 3 4 vddcore 5 gnd 6 vddout 7 vddin 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 gndana 23 24 vddana 25 26 27 28 29 seg14 30 seg13 31 seg12 32 seg8 48 seg7 47 seg6 46 seg5 45 seg4 44 seg3 43 seg2 42 seg1 41 seg0 40 vlcdin 39 gnd 38 biasl 37 biash 36 vlcd 35 capl 34 caph 33 seg9 49 seg10 50 seg11 51 vddio 52 53 54 55 56 57 58 59 60 vddio 61 62 63 gnd 64 com3 com2 com1 com0 seg15 seg16 seg17 seg18 seg19 seg20 seg21 seg22 1 2 3 4 vddcore 5 gnd 6 vddout 7 vddin 8 9 10 11 12 13 14 15 16 gndana 17 18 vddana 19 seg8 20 com3 21 com2 22 com1 23 com0 24 seg4 36 seg3 35 seg2 34 seg1 33 seg0 32 vlcdin 31 gnd 30 biasl 29 biash 28 vlcd 27 capl 26 caph 25 seg5 37 seg6 38 seg7 39 vddio 40 seg9 41 seg10 42 seg11 43 seg12 44 vddio 45 46 47 gnd 48 tqfp48/qfn48 tqfp64/qfn64 tqfp100 lcda cluster lcdb cluster lcdc cluster
48 42023e?sam?07/2013 atsam4l8/l4/l2 connected to an external voltage source (1.8-3.6v). lcdb cluster is not available in 64 and 48 pin packages table 5-1. lcd powering when using the internal voltage pump package segments in use vddio lcdb vddio lcdc 100-pin packages [1,24] 1.8-3.6v 1.8-3.6v [1, 32] nc 1.8-3.6v [1, 40] nc nc 64-pin packages [1,15] - 1.8-3.6v [1, 23] -nc 48-pin packages [1,9] - 1.8-3.6v [1,13] -nc vlcdin gnd gpios lcd vpump caph capl biash biasl vlcd vddio lcdb domain gpios vddio gpios lcdc domain switch on switch on nc nc 1.8?3.6v vlcdin gnd gpios lcd vpump caph capl biash biasl vlcd vddio lcdb domain gpios vddio gpios lcdc domain switch on switch off nc 1.8?3.6v vlcdin gnd gpios lcd vpump caph capl biash biasl vlcd vddio lcdb domain gpios vddio gpios lcdc domain switch off switch off 1.8?3.6v 1.8?3.6v lcda domain lcda domain lcda domain 1.8?3.6v up to 4x40 segments no gpio in lcd clusters up to 4x32 segments up to 8 gpios in lcdc clusters up to 4x24 segments up to 16 gpios in lcdb & lcdc clusters
49 42023e?sam?07/2013 atsam4l8/l4/l2 5.2.4 power-up sequence 5.2.4.1 maximum rise rate to avoid risk of latch-up, the rise rate of the power supplies must not exceed the values described in table 42-3 on page 1121 . 5.2.4.2 minimum rise rate the integrated power-on reset (por33) circuitry monitoring the vddin powering supply requires a minimum rise rate for the vddin power supply. see table 42-3 on page 1121 for the minimum rise rate value. if the application can not ensure that the minimum rise rate condition for the vddin power sup- ply is met, the following configuration can be used: ? a logic ?0? value is applied during power-up on pin reset_n until vddin rises above 1.6 v. 5.3 startup considerations this section summarizes the boot sequence of the atsam4l8/l4/l2. the behavior after power- up is controlled by the power manage r. for specific details, refer to section 10. ?power manager (pm)? on page 108 . 5.3.1 starting of clocks after power-up, the device will be held in a reset state by th e power-up circuitry for a short time to allow the power to stabilize throughout the device. after re set, the device will use the system rc oscillator (rcsys) as clock source. refer to section 42. ?electrical characteristics? on page 1120 for the frequency for this oscillator. on system start-up, the dfll and the plls are di sabled. only the necessa ry clocks are active allowing software execution. refer to section 10-5 ?maskable modul e clocks in atsam4l.? on page 119 to know the list of peripheral clock r unning.. no clocks have a divided frequency; all parts of the system rece ive a clock with the same frequen cy as the system rc oscillator. 5.3.2 fetching of initial instructions after reset has been released, the cortex m4 cpu starts fetching pc and sp values from the reset address, which is 0x00000000. refer to the arm architecture reference manual for more information on cpu startup. this address points to the first address in the internal flash. the code read from the internal flash is free to configure the clock system and clock sources. 5.4 power-on-reset, brownout and supply monitor the sam4l embeds four features to monitor, warm, and/or reset the device: ? por33: power-on-reset on vddana ? bod33: brownout detector on vddana ? por18: power-on-reset on vddcore ? bod18: brownout detector on vddcore
50 42023e?sam?07/2013 atsam4l8/l4/l2 figure 5-6. supply monitor schematic 5.4.1 power-on-reset on vddana por33 monitors vddana. it is always activated and monitors voltage at startup but also during all the power save mode. if vddana goes below the threshold voltage, the entire chip is reset. 5.4.2 brownout detector on vddana bod33 monitors vddana. refer to section 12. ?backup system control interface (bscif)? on page 160 to get more details. 5.4.3 power-on-reset on vddcore por18 monitors the inte rnal vddcore. refer to section 12. ?backup system control interface (bscif)? on page 160 to get more details. 5.4.4 brownout detector on vddcore once the device is startup, the bod18 monitors the internal vddcore. refer to section 12. ?backup system control interface (bscif)? on page 160 to get more details. por33 bod33 bod18 vddana gndana vddana por18 dual output trimmable voltage regulator vddcore
51 42023e?sam?07/2013 atsam4l8/l4/l2 6. low power techniques the atsam4l8/l4/l2 supports multiple power configurations to allow the user to optimize its power consumption in different use cases. the backup power manager (bpm) implements dif- ferent solutions to reduce the power consumption: ? the power save modes intended to reduce the logic activity and to adapt the power configuration. see ?power save modes? on page 51 . ? the power scaling intended to scale the power configuration (voltage scaling of the regulator). see ?power scaling? on page 56 . these two techniques can be combined together. figure 6-1. power scaling and power save mode overview 6.1 power save modes refer to section 5. ?power and startup considerations? on page 42 to get definition of the core and the backup domains. sleep1 wait1 ret1 bkup1 run1 power scaling max frequency = 36mhz normal speed flash nominal voltage bpm.pmcon.ps=0 max frequency = 12mhz normal speed flash reduced voltage bpm.pmcon.ps=1 reset run sleep0 wait0 ret0 bkup0 run0 sleep cpu clock off 4 sub-modes wait all clocks off sleepwalking retention all clocks off full chip retention backup core domain off power save modes max frequency = 48mhz high speed flash nominal voltage bpm.pmcon.ps=2 sleep2 wait2 ret2 bkup2 run2
52 42023e?sam?07/2013 atsam4l8/l4/l2 at power-up or after a reset, the atsam4l8/l4/l2 is in the run0 mode. only the necessary clocks are enabled allowing software execution. the power manager (pm) can be used to adjust the clock frequencies and to enable and disable the peripheral clocks. when the cpu is entering a power save mode, the cpu stops executing code. the user can choose between four power save modes to optimize power consumption: ? sleep mode: the cortex-m4 core is stopped , optionally some cl ocks are stopped, peripherals are kept running if enabled by the user. ? wait mode: all clock sources are stopped, the core and all the peripherals are stopped except the modules running with the 32khz clock if enabled. this is the lowest power configuration where sleepwalking is supported. ? retention mode: similar to the wait mode in terms of clock activity. this is the lowest power configuration where the logic is retained. ? backup mode: the core domain is powered off, the backup domain is kept powered. a wake up source exits the system to the run mode from which the power save mode was entered. a reset source always exits the system from the power save mode to the run0 mode. the configuration of the i/o lines are maintained in all power save modes. refer to section 11. ?backup power manager (bpm)? on page 139 . 6.1.1 sleep mode the sleep mode allows power optimizati on with the fastes t wake up time. the cpu is stopped. to further reduce power consumption, the user can switch off modules- clocks and synchronous clock sources through the bpm.pmcon.sleep field (see table 6-1 ). the required modules will be halted regardless of the bit settings of the mask registers in the power manager (pm.ah bmask, pm.apbxmask). notes: 1. from modules with clock running. 2. osc32k and rc32k will only remain operational if pre-enabled. 6.1.1.1 entering sleep mode the sleep mode is en tered by executing the wfi instruction. additionally, if the sleeponexit bit in the cort ex-m4 system control register (scr) is set, the sleep mode will also be entered when the cortex-m4 exits the lowest priority isr. this table 6-1. sleep mode configuration bpm.psave.sleep cpu clock ahb clocks apb clocks gclk clock sources: osc, rcfast, rc80m, pll, dfll rcsys osc32k rc32k (2) wake up sources 0 stop run run run run run any interrupt 1 stop stop run run run run any interrupt (1) 2 stop stop stop run run run any interrupt (1) 3 stop stop stop stop run run any interrupt (1)
53 42023e?sam?07/2013 atsam4l8/l4/l2 mechanism can be useful for applications that only require the processor to run when an inter- rupt occurs. before entering the sleep mode , the user must configure: ? the sleep mode configuration fiel d (bpm.pmcon.sleep), refer to table 6-1 . ? the scr.sleepdeep bit to 0. (see the power management section in the arm cortex-m4 processor chapter). ? the bpm.pmcon.ret bit to 0. ? the bpm.pmcon.bkup bit to 0. 6.1.1.2 exiting sleep mode the nvic wakes the system up when it detects any non-masked interrupt with sufficient priority to cause exception entry. the system goes ba ck to the run mode from which the sleep mode was entered. the cpu and affected modules are restarted. note that even if an interrupt is enabled in sleep mode, it will not trigge r if the source module is not clocked. 6.1.2 wait mode and retention mode the wait and retention modes allow achievin g very low power cons umption while main- taining the core domain powered-on. internal sram and registers contents of the core domain are preserved. in these modes, all clocks are stopped except the 32khz clocks (osc32k, rc32k) which are kept running if enabled. in retention mode, the sleepwalking featur e is not supported and must not be used. 6.1.2.1 entering wait or retention mode the wait or retention modes are entered by ex ecuting the wfi instruction with the follow- ing settings: ? set the scr.sleepdeep bit to 1. (see the po wer management section in the arm cortex- m4 processor chapter). ? set the bpm.psave.bkup bit to 0. ? set the bpm.pmcon.ret bit to retention or wait mode. sleeponexit feature is also available. see ?entering sleep mode? on page 52 . 6.1.2.2 exiting wait or retention mode in wait or retention modes, synchronous clocks are stopped preventing interrupt sources from triggering. to wakeup the system, asynchronous wake up sources (ast, eic, usbc ...) should be enabled in the peripheral (refer to the documentation of the peripheral). the pm.awen (asynchronous wake up enable) regi ster should also be enabled for all peripheral except for eic and ast. when the enabled asynchronous wake up event occurs and the system is waken-up, it will gen- erate either: ? an interrupt on the pm wake interr upt line if enabled (refer to section 10. ?power manager (pm)? on page 108 ). in that case, the pm.wcause register indicates the wakeup source. ? or an interrupt directly from the peripheral if enabled (refer to the section of the peripheral). when waking up, the system goes back to the run mode mode from which the wait or retention mode was entered.
54 42023e?sam?07/2013 atsam4l8/l4/l2 6.1.3 backup mode the backup mode allows achieving the lowest po wer consumption possible in a system which is performing periodic wake-ups to perform tasks but not requiring fast startup time. the core domain is powered-off. the internal sram and register contents of the core domain are lost. the backup domain is kept powered- on. the 32khz clock (rc32k or osc32k) is kept running if enabled to feed modules that require clocking. in backup mode, the configuration of the i/o lines is preserved. refer to section 11. ?backup power manager (bpm)? on page 139 to have more details. 6.1.3.1 entering backup mode the backup mode is entered by using the wfi instruction with the following settings: ? set the scr.sleepdeep bit to 1. (see the po wer management section in the arm cortex- m4 processor chapter). ? set the bpm.psave.bkup bit to 1. 6.1.3.2 exiting backup mode exit from backup mode happens if a reset occurs or if an enabled wake up event occurs. the reset sources are: ? bod33 reset ? bod18 reset ? wdt reset ? external reset in reset_n pin the wake up sources are: ? eic lines (level transition only) ? bod33 interrupt ? bod18 interrupt ? ast alarm, periodic, overflow ? wdt interrupt the rc32k or osc32k should be used as clock source for modules if required. the pmcon.ck32s is used to select on e of these two 32khz clock sources. exiting the backup mode is triggered by: ? a reset source: an internal reset sequence is performed according to the reset source. once vddcore is stable and has the correct value according to run0 mode, the internal reset is released and program execution starts. the corresponding reset source is flagged in the reset cause register (rcause) of the pm. ? a wake up source: the backup domain is not reset. an internal reset is generated to the core domain, and the system switches back to the previous run mode. once vddcore is stable and has the correct value, the internal reset in the core domain is released and program execution starts. the bkup bit is set in the reset cause register (rcause) of the pm. it allows the user to discriminate between the reset cause and a wake up cause from the backup mode. the wake up cause can be found in the backup wake up cause register (bpm.bkupwcause).
55 42023e?sam?07/2013 atsam4l8/l4/l2 6.1.4 wakeup time 6.1.4.1 wakeup time from sleep mode the latency depends on the clock sources wake up time. if the clock sources are not stopped, there is no latency to wake the clocks up. 6.1.4.2 wakeup time from wait or retention mode the wake up latency consists of: ? the switching time from the lo w power configuration to the run mode power configuration. by default, the switching time is completed when all the voltage regulation system is ready. to speed-up the startup time, the user can set the fast wakeup bit in bpm.pmcon register. ? the wake up time of the rc os cillator used to start the system up. by default, the rcsys oscillator is used to startup the system. the user can use another clock source (rcfast for example) to speed up the startup time by configuring the pm.fastwkup register. refer to section 10. ?power manager (pm)? on page 108 . ? the flash memory wake up time. to have the shortest wakeup time, the user should: - set the bpm.pmcon.fastwkup bit. - configure the pm.fastsleep.fastrcosc field to use the rcfast main clock. - enter the wait or retention mode upon a wakeup, this is required to keep the main clock connected to rcfast until the voltage regulation system is fully ready (when bpm.is r.psok bit is one). during this wakeup period, the flashcalw module is automatically configured to operate in ?1 wait state mode?. 6.1.4.3 wake time from backup mode it is equal to the core domain logic reset latency (similar to the reset latency caused by an exter- nal reset in reset_n pin) added to the time required for the voltage regulation system to be stabilized.
56 42023e?sam?07/2013 atsam4l8/l4/l2 6.1.5 power save mode summary table the following table shows a summary of the main power save modes: 6.2 power scaling the power scaling technique consists of adjusting the internal regulator output voltage (voltage scaling) to reduce the power consumption. according to the requirements in terms of perfor- mance, operating modes, and current consumptio n, the user can select the power scaling configuration that fits the best with its application. the power scaling configuration field (pmcon.ps) is provided in the backup power manager (bpm) module. in run mode, the user can adjust on the fly the power scaling configuration the figure 6.1 summarizes the different combination of the power scaling configuration which can be applied according to the power save mode. power scaling from a current power configuration to a new power configuration is done by halt- ing the cpu execution power scaling occurs afte r a wfi instruction. the system is halted until the new power configu- ration is stabilized. after handling the pm interrupt, th e system resumes from wfi. to scale the power, the following sequence is required: ? check the bpm.sr.psok bit to make sure the current power configuration is stabilized. table 6-2. power save mode configuration summary mode mode entry wake up sources core domain backup domain sleep wfi scr.sleepdeep bit = 0 bpm.pmcon.bkup bit = 0 any interrupt cpu clock off other clocks off depending on the bpm.pmcon.sleep field see ?sleep mode? on page 52 clocks off depending on the bpm.pmcon.sleep field see ?sleep mode? on page 52 wait wfi scr.sleepdeep bit = 1 bpm.pmcon.ret bit = 0 bpm.pmcon.bkup bit = 0 pm wake interrupt all clocks are off core domain is retained all clocks are off except rc32k or osc32k if running retention wfi scr.sleepdeep bit = 1 bpm.pmcon.ret bit = 1 bpm.pmcon.bkup bit = 0 pm wake interrupt all clocks are off core domain is retained all clocks are off except rc32k or osc32k if running backup wfi + scr.sleepdeep bit = 1 + bpm.pmcon.bkup bit = 1 eic interrupt bod33, bod18 interrupt and reset ast alarm, periodic, overflow wdt interrupt and reset external reset on reset_n pin off (not powered) all clocks are off except rc32k or osc32k if running
57 42023e?sam?07/2013 atsam4l8/l4/l2 ? set the clock frequency to be supported in both power configurations. ? set the high speed read mode of the flash to be supported in both power scaling configurations ? only relevant when entering or exiting bpm.pmcon.ps=2 ? configure the bpm.pmcon.ps field to the new power configuration. ? set the bpm.pmcon.pscreq bit to one. ? disable all the interrupts except the pm wcause interrupt and enable only the psok asynchronous event in the awen register of pm. ? execute the wfi instruction. ? wait for pm interrupt. the new power configuration is reached when the system is waken up by the pm interrupt thanks to the psok event. by default, all features are available in all po wer scaling modes. howe ver some specific fea- tures are not available in ps1 (bpm.pmcon.ps=1) mode : ?usb ?dfll ?pll ? programming/erasing in flash
58 42023e?sam?07/2013 atsam4l8/l4/l2 7. memories 7.1 product mapping figure 7-1. atsam4l8/l4/l2 product mapping system reserved reserved hramc1 global memory space peripherals code internal flash reserved 0x00000000 0x00800000 0x1fffffff code sram undefined peripherals reserved 0x00000000 0x20000000 0x40000000 0x60000000 0xffffffff 0x22000000 0x5fffffff sram hramc0 reserved 0x20000000 0x20010000 0x21000000 0x210007ff 0x21ffffff peripheral bridge a reserved peripheral bridge b peripheral bridge c peripheral bridge d aesa 0x400e0000 0x400f0000 0x40100000 0x400b0000 0x400a0000 0x40000000 0x400b0100 system controller twim2 catb dacc reserved reserved i2sc spi reserved tc0 tc1 twims0 twims1 usart0 usart1 usart2 usart3 reserved adcife acifc reserved gloc abdacb trng parc reserved 0x40000000 0x40004000 0x40008000 0x4000c000 0x40010000 0x40014000 0x40018000 0x4001c000 0x40020000 0x40024000 0x40028000 0x4002c000 0x40030000 0x40034000 0x40038000 0x4003c000 0x40040000 0x40044000 0x40060000 0x40064000 0x40068000 0x4006c000 0x40070000 0x40074000 0x40078000 twim3 0x4007c000 0x40080000 lcdca reserved 0x40084000 0x4009ffff picouart peripheral bridge c pm scif chipid freqm gpio reserved bpm bscif ast wdt eic reserved 0x400e0000 0x400e0740 0x400e0800 0x400e0c00 0x400e1000 0x400e1800 0x400f0000 0x400f0400 0x400f0800 0x400f0c00 0x400f1000 0x400f1400 peripheral bridge d 0x400fffff 0x400f1800 0x400effff peripheral bridge b flashcalw hmatrix smap crccu picocache reserved 0x400a0000 0x400a0400 0x400a1000 0x400a2000 0x400a3000 0x400a4000 0x400a5000 pdca usbc pevc 0x400a6000 0x400a6400 0x400affff peripheral bridge a itm dwt fpb reserved scs reserved tpiu reserved external ppb rom table 0xe0000000 0xe0000000 0xe0001000 0xe0002000 0xe0003000 0xe000e000 0xe000f000 0xe0040000 0xe0041000 0xe0042000 0xe00ff000 0xe0100000 reserved 0xffffffff system
59 42023e?sam?07/2013 atsam4l8/l4/l2 7.2 embedded memories ? internal high-speed flash ? 512kbytes (atsam4lx8) ? 256kbytes (atsam4lx4) ? 128kbytes (atsam4lx2) ? pipelined flash architecture, allowing burst r eads from sequen tial flash loca tions, hiding penalty of 1 wait state access ? pipelined flash architecture typically reduce s the cycle penalty of 1 wait state operation compared to 0 wait state operation ? 100 000 write cycles, 15-year data retention capability ? sector lock capabilities, boot loader protection, security bit ? 32 fuses, erased during chip erase ? user page for data to be preserved during chip erase ? internal high-speed sram, sing le-cycle access at full speed ? 64kbytes (atsam4lx8) ? 32kbytes (atsam4lx4, atsam4lx2) 7.3 physical memory map the system bus is implemented as a bus matrix . all system bus addresses are fixed, and they are never remapped in any way, not even during boot. the 32-bit physical address space is mapped as follows: table 7-1. atsam4l8/l4/l2 physical memory map memory start address size size atsam4lx4 atsam4lx2 embedded flash 0x00000000 256kbytes 128kbytes embedded sram 0x20000000 32kbytes 32kbytes cache sram 0x21000000 4kbytes 4kbytes peripheral bridge a 0x40000000 64kbytes 64kbytes peripheral bridge b 0x400a0000 64kbytes 64kbytes aesa 0x400b0000 256 bytes 256 bytes peripheral bridge c 0x400e0000 64kbytes 64kbytes peripheral bridge d 0x400f0000 64kbytes 64kbytes memory start address size at s a m 4 l x 8 embedded flash 0x00000000 512kbytes embedded sram 0x20000000 64kbytes cache sram 0x21000000 4kbytes peripheral bridge a 0x40000000 64kbytes peripheral bridge b 0x400a0000 64kbytes
60 42023e?sam?07/2013 atsam4l8/l4/l2 aesa 0x400b0000 256 bytes peripheral bridge c 0x400e0000 64kbytes peripheral bridge d 0x400f0000 64kbytes memory start address size at s a m 4 l x 8 table 7-2. flash memory parameters device flash size ( flash_pw ) number of pages ( flash_p )page size ( flash_w ) atsam4lx8 512kbytes 1024 512 bytes atsam4lx4 256kbytes 512 512 bytes atsam4lx2 128kbytes 256 512 bytes
61 42023e?sam?07/2013 atsam4l8/l4/l2 8. debug and test 8.1 features ? ieee1149.1 compliant jtag debug port ? serial wire debug port ? boundary-scan chain on all digital pins for board-level testing ? direct memory access and programmi ng capabilities th rough debug ports ? flash patch and breakpoint (fpb) unit for im plementing breakpoints and code patches ? data watchpoint and trace (dwt) unit for implem enting watchpoints, da ta tracing, and system profiling ? instrumentation trace macrocell (itm) for support of printf style debugging ? chip erase command and status ? unlimited flash user page read access ? cortex-m4 core reset source ? crc32 of any memory accessible through the bus matrix ? debugger hot plugging 8.2 overview debug and test features are made available to external tools by: ? the enhanced debug port (edp) embedding: ? a serial wire debug port (sw-dp) part of the arm coresight architecture ? an ieee 1149.1 jtag debug debug port (jtag-dp) part of the arm coresight architecture ? a supplementary ieee 1149.1 jtag tap machine that implem ents the boundary scan feature ? the system manager acces port (smap) providing unlimited flash user page read access, crc32 of any memory accessible through the bus matrix and cortex-m4 core reset services ? the ahb access port (ahb-ap) providing dir ect memory access, pr ogramming capabilities and standard debugging functions ? the instrumentation trace macrocell part of the arm coresight architecture for more information on arm debug components, refer to: ? armv7-m architectu re reference manual ? arm debug interface v5.1 architecture specification document ? arm coresight archit ecture specification ? arm etm architecture specification v3.5 ? arm cortex-m4 technical reference manual
62 42023e?sam?07/2013 atsam4l8/l4/l2 8.3 block diagram figure 8-1. debug and test block diagram 8.4 i/o lines description refer to section 8.7.4 ?i/o lines description? on page 67 . swj-dp ahb-ap tck reset_n reset controller bscan-tap tdo tdi tms por boundary scan smap core reset request smap enhanced debug port dap bus hot_plugging jtag-filter ahb cortex-m4 nvic fpb dwt itm core instr data private peripheral bus (ppb) tpiu port muxing htop apb ahb cortex-m4 core reset ahb m m s chip erase edp core reset request system bus matrix
63 42023e?sam?07/2013 atsam4l8/l4/l2 8.5 product dependencies 8.5.1 i/o lines refer to section 8.7.5.1 ?i/o lines? on page 68 . 8.5.2 power management refer to section 8.7.5.2 ?power management? on page 68 . 8.5.3 clocks refer to section 8.7.5.3 ?clocks? on page 68 . 8.6 core debug figure 8-2 shows the debug architecture used in the sam4l. the cortex-m4 embeds four func- tional units for debug: ? fpb (flash patch breakpoint) ? dwt (data watchpoint and trace) ? itm (instrumentation trace macrocell) ? tpiu (trace port interface unit) the debug architecture information that follows is mainly dedicated to developers of swj-dp emulators/probes and debugging tool vendors for cortex-m4 based microcontrollers. for further details on swj-dp see the cortex-m4 technical reference manual. figure 8-2. debug architecture 8.6.1 fpb (flash patch breakpoint) the fpb: ? implements hardware breakpoints ? patches (on the fly) code and data being fetched by the cortex-m4 core from code space with data in the system space. definition of code and system spaces can be found in the system address map section of the armv7-m architecture reference manual. 4 watchpoints pc sampler data address sampler data sampler interrupt trace cpu statistics dwt 6 breakpoints fpb software trace 32 channels time stamping itm swd/jtag swj-dp swo trace tpiu
64 42023e?sam?07/2013 atsam4l8/l4/l2 the fpb unit contains: ? two literal comparators for matching against literal loads from code space, and remapping to a corresponding area in system space. ? six instruction comparators for matching against instruction fetches from code space and remapping to a corresponding area in system space. ? alternatively, comparators can also be configured to generate a breakpoint instruction to the processor core on a match. 8.6.2 dwt (data watchpoint and trace) the dwt contains four comparators which can be configured to generate the following: ? pc sampling packets at set intervals ? pc or data watchpoint packets ? watchpoint event to halt core the dwt contains counters for the items that follow: ? clock cycle (cyccnt) ? folded instructions ? load store unit (lsu) operations ? sleep cycles ? cpi (all instruction cycles except for the first cycle) ? interrupt overhead 8.6.3 itm (instrumentation trace macrocell) the itm is an application driven trace source that supports printf style debugging to trace oper- ating system (os) and application events, and emits diagnostic system information. the itm emits trace information as packets which can be generated by three different sources with sev- eral priority levels: ? software trace : this can be done thanks to the printf style debugging. for more information, refer to section ?how to configure the itm:? . ? hardware trace : the itm emits packets generated by the dwt. ? time stamping : timestamps are emitted relative to packets. the itm contains a 21-bit counter to generate the timestamp. how to configure the itm: the following example describes how to output trace data in asynchronous trace mode. ? configure the tpiu for asynchronous trace mode (refer to section ?5.4.3. how to configure the tpiu? ) ? enable the write accesses into the itm registers by writing ?0xc5acce55? into the lock access register (address: 0xe0000fb0) ? write 0x00010015 into the trace control register: ?enable itm ? enable synchronization packets ? enable swo behavior
65 42023e?sam?07/2013 atsam4l8/l4/l2 ? fix the atb id to 1 ? write 0x1 into the trace enable register: ? enable the stimulus port 0 ? write 0x1 into the trace privilege register: ? stimulus port 0 only accessed in privileged mode (clearing a bit in this register will result in the corresponding stimulus port being accessible in user mode.) ? write into the stimulus port 0 register: tpiu (trace port interface unit) the tpiu acts as a bridge between the on-chip trace data and the instruction trace macro- cell (itm). the tpiu formats and transmits trace data off-chip at frequencies asynchronous to the core. asynchronous mode: the tpiu is configured in asynchronous mode, trace data are output using the single trac- eswo pin. the traceswo signal is multiplexed with the tdo signal of the jtag debug port. as a consequence, asynchronous trace mode is only available when the serial wire debug mode is selected since tdo signal is used in jtag debug mode. two encoding formats are avail able for the single pin output: ? manchester encoded stream. this is the reset value. ? nrz_based uart byte structure 5.4.3. how to configure the tpiu this example only concerns the asynchronous trace mode. ? set the trcena bit to 1 into the debug exception and monitor register (0xe000edfc) to enable the use of trace and debug blocks. ? write 0x2 into the selected pin protocol register ? select the serial wire output ? nrz ? write 0x100 into the formatter and flush control register ? set the suitable clock prescaler value into the async clock prescaler register to scale the baud rate of the asynchronous output (this can be done automatically by the debugging tool).
66 42023e?sam?07/2013 atsam4l8/l4/l2 8.7 enhanced debug port (edp) rev.: 1.0.0.0 8.7.1 features ? ieee1149.1 compliant jtag debug port ? serial wire debug port ? boundary-scan chain on all digital pins for board-level testing ? debugger hot-plugging ? smap core reset request source 8.7.2 overview the enhanced debug port embeds a standard arm debug port plus some specific hardware intended for testability and activati on of the debug port features. all the inform ation related to the arm debug interface implementation can be found in the arm debug interface v5.1 architec- ture specification document. it features: ? a single debug port (swj-dp), that provides the external physical connection to the interface and supports two dp implementations: ? the jtag debug port (jtag-dp) ? the serial wire debug port (sw-dp) ? a supplementary jtag tap (bscan-tap) connected in parallel with the jtag-dp that implements the boundary scan instructions detailed in ? a jtag-filter module that mo nitors tck and reset_n pins to handle specific features like the detection of a debugger hot-plugging and the request of reset of the cortex-m4 at startup. the jtag-filter module detects the presence of a debugger. when present, jtag pins are automatically assigned to the enhanced debug port(edp). if the swj-dp is switched to the sw mode, then tdi and tdo alternate functions are released. the jtag-filter also implements a cpu halt mechanism. when trigge red, the cortex-m4 is maintained under reset after the exter- nal reset is released to prevent any system corruption during later programmation operations.
67 42023e?sam?07/2013 atsam4l8/l4/l2 8.7.3 block diagram figure 8-3. enhanced debug port block diagram 8.7.4 i/o lines description tck reset_n tdo tdi tms boundary_scan jtag-filter edp core reset request enhanced debug port dap bus sw-dp swj-dp jtag-dp bscan-tap traceswo swclk swdio tdo tck tms tdi tdo tck tms tdi tck reset_n test_tap_sel table 8-1. i/o lines description name jtag debug port swd debug port type description type description tck/swclk i debug clock i serial wire clock tdi i debug data in - na tdo/traceswo o debug data out o trace asynchronous data out tms/swdio i debug mode select i/o serial wire input/output reset_n i reset i reset
68 42023e?sam?07/2013 atsam4l8/l4/l2 8.7.5 product dependencies 8.7.5.1 i/o lines the tck pin is dedicated to the edp. the other debug port pins default after reset to their gpio functionality and are automatically reassigned to the jtag functionalities on detection of a debugger. in serial wire mode, tdi and tdo can be used as gpio functions . note that in serial wire mode tdo can be used as a single pin trace output. 8.7.5.2 power management when a debugger is present, the connection is k ept alive allowing debug operations. as a side effect, the power is never turned off. the hot plugging functionality is always available except when the system is in backup power save mode. 8.7.5.3 clocks the swj-dp uses the external tck pin as its cloc k source. this clock must be provided by the external jtag master device. some of the jtag instructions are used to a ccess an access port (smap or ahb-ap). these instructions require the cpu clock to be running. if the cpu clock is not present because the cpu is in a power save mode where this clock is not provided, the power manager(pm) will automatically restor e the cpu clock on detection of a debug access. the rcsys clock is used as cpu clock when the external reset is applied to ensure correct access port operations. 8.7.6 module initialization this module is enabled as soon as a tck falling edge is detected when reset_n is not asserted (refer to section 8.7.7 below). moreover, the module is synchronously reseted as long as the tap machine is in the test_logic_reset (tlr ) state. it is adv ised asserting tms at least 5 tck clock peri ods after the debugger has been detected to ensure the module is in the tlr state prior to any op eration. this module also has th e ability to maintain the cortex-m4 under reset (refer to the section 8.7.8 ?smap core reset request source? on page 69 ). 8.7.7 debugger hot plugging the tck pin is dedicated to the edp. after re set has been released, the edp detects that a debugger has been attached when a tc k falling edge arises. figure 8-4. debugger hot plugging detection timings diagram tck reset_n hot_plugging tck reset_n hot plugging
69 42023e?sam?07/2013 atsam4l8/l4/l2 the debug port pins assignation is then forced to the edp function even if they were already assigned to another module. this allows to conn ect a debugger at any time without reseting the device. the connection is non-intrusive meaning that the chip will continue its execution without being disturbed. the cpu can of course be halted later on by issuing cortex-m4 ocd features. 8.7.8 smap core reset request source the edp has the ability to send a request to t he smap for a cortex-m4 co re reset. the proce- dure to do so is to hold tck low until reset_n is released. this mechanism aims at halting the cpu to prevent it from changing the system configuration while the smap is operating. figure 8-5. smap core reset request timings diagram the smap can de-assert the core reset request for this operation, refer to section 8.8.8 ?cortex- m4 core reset source? on page 77 . 8.7.9 swj-dp the cortex-m4 embeds a swj-dp debug port which is the standard coresight ? debug port. it combines serial wire debug port (sw-dp), from 2 to 3 pins and jtag debug port(jtag-dp), 5 pins. by default, the jtag debug port is active. if the host debugger wants to switch to the serial wire debug port, it must provide a dedicated jtag sequence on tms/swdio and tck/swclk which disables jtag-dp and enables sw-dp. when the edp has been switched to serial wire mode, tdo/traceswo can be used for trace (for more information refer to the section below). the asynchronous trace output (trac- eswo) is multiplexed with tdo. so the asynchro nous trace can only be used with sw-dp, not jtag-dp. the swj-dp provides access to the ahb-ap and smap access ports which have the following apsel value: refer to the arm debug interface v5.1 architec ture specification for more details on swj-dp. reset request tck reset_n edp core reset request figure 8-6. access ports apsel acces port (ap) apsel ahb-ap 0 smap 1
70 42023e?sam?07/2013 atsam4l8/l4/l2 8.7.10 sw-dp and jtag-dp selection mechanism after reset, the swj-dp is in jtag mode but it can be switched to the serial wire mode. debug port selection mechanism is done by sending specific swdiotms sequence. the jtag-dp is selected by default after reset. ? switch from jtag-dp to sw-dp. the sequence is: ? send more than 50 swclktck cycles with swdiotms = 1 ? send the 16-bit sequence on swdiotms = 0111100111100111 (0x79e7 msb first) ? send more than 50 swclktck cycles with swdiotms = 1 ? switch from swd to jtag. the sequence is: ? send more than 50 swclktck cycles with swdiotms = 1 ? send the 16-bit sequence on swdiotms = 0011110011100111 (0x3ce7 msb first) send more than 50 swclktck cycles with swdiotms = 1 note that the bscan-tap is not available w hen the debug port is switched to serial mode. boundary scan instructions are not available. 8.7.11 jtag-dp and bscan-tap selection mechanism after the dp has been enabled, the bscan-tap and the jtag-dp run simultaneously has long as the swj-dp remains in jtag mode. each tap captures simultaneously the jtag instruc- tions that are shifted. if an instruction is re cognized by the bscan-tap, then the bscan-tap tdo is selected instead of the swj-dp tdo. tdo selection changes dynamically depending on the current instruction held in the bscan-tap instruction register.
71 42023e?sam?07/2013 atsam4l8/l4/l2 8.7.12 jtag instructions summary the implemented jtag instructions are shown in the table below. table 8-2. implemented jtag instructions list ir instruction value instruction description availability when protected component b0000 extest select boundary-scan chain as data register for testing circuitry external to the device. yes bscan-tap b0001 sample_preload take a snapshot of external pin values without affecting system operation. yes b0100 intest select boundary-scan chain for internal testing of the device. yes b0101 clamp bypass device through bypass register, while driving outputs from boundary-scan register. yes b1000 abort arm jtag-dp instruction yes swj-dp (in jtag mode) b1010 dpacc arm jtag-dp instruction yes b1011 apacc arm jtag-dp instruction yes b1100 - reserved yes b1101 - reserved yes b1110 idcode arm jtag-dp instruction yes b1111 bypass bypass this device through the bypass register. yes
72 42023e?sam?07/2013 atsam4l8/l4/l2 8.7.13 security restrictions the sam4l provide a security rest rictions mechanism to lock ac cess to the device. the device in the protected state when the flash security bi t is set. refer to section flash controller for more details. when the device is in the protected state the ah b-ap is locked. full access to the ahb-ap is re- enabled when the protected state is released by issuing a chip erase command. note that the protected state will read as programmed only after the system has been reseted. 8.7.13.1 notation table 8-4 on page 72 shows bit patterns to be shifted in a format like " p01 ". each character cor- responds to one bit, and eight bits are grouped t ogether for readab ility. the least significant bit is always shifted first, and the most significant bit shifted last. the symbols used are shown in table 8-3 . in many cases, it is not required to shift all bits through the data register. bit patterns are shown using the full width of the shift register, but the suggested or required bits are emphasized using bold text. i.e. given the pattern " 01010101 xxxxxxxx xxxxxxxx xxxxxxxx", the shift register is 32 bits, but the test or debug unit may choose to shift only 8 bits " 01010101 ". the following describes how to interpret the fields in the instruction description tables: table 8-3. symbol description symbol description 0 constant low value - always reads as zero. 1 constant high value - always reads as one. p the chip protected state. x a don?t care bit. any value can be shifted in, and output data should be ignored. e an error bit. read as one if an error occurred, or zero if not. b a busy bit. read as one if the smap was busy, or zero if it was not. s startup done bit. read as one if the system has started-up correctly. table 8-4. instruction description instruction description ir input value shows the bit pattern to shift into ir in t he shift-ir state in order to select this instruction. the pattern is show both in binary and in hexadecimal form for convenience. example: 1000 (0x8) ir output value shows the bit pattern shifted out of ir in t he shift-ir state when this instruction is active. example: p00s
73 42023e?sam?07/2013 atsam4l8/l4/l2 8.7.14 jtag instructions refer to the arm debug interface v5.1 architecture specification for more details on abort, dpacc, apacc and idcode instructions. 8.7.14.1 extest this instruction selects the boundary-scan chain as data register for testing circuitry external to the chip package. the contents of the latched outputs of the boundary-scan chain is driven out as soon as the jtag ir-register is loaded with the extest instruction. starting in run-test/idle, the extest instruction is accessed the following way: 1. select the ir scan path. 2. in capture-ir: the ir output value is latched into the shift register. 3. in shift-ir: the instruction register is shifted by the tck input. 4. in update-ir: the data from the boundary-scan chain is applied to the output pins. 5. return to run-test/idle. 6. select the dr scan path. 7. in capture-dr: the data on the external pins is sampled into the boundary-scan chain. 8. in shift-dr: the boundary-scan chain is shifted by the tck input. 9. in update-dr: the data from the scan chain is applied to the output pins. 10. return to run-test/idle. 8.7.14.2 sample_preload this instruction takes a snap-shot of the input/ output pins without affect ing the system operation, and pre-loading the scan chain without updating the dr-latch. the boundary-scan chain is selected as data register. starting in run-test/idle, the device identification register is accessed in the following way: dr size shows the number of bits in the data register chain when this instruction is active. example: 32 bits dr input value shows which bit pattern to shift into the data register in the shift-dr state when this instruction is active. dr output value shows the bit pattern shifted out of the dat a register in the sh ift-dr state when this instruction is active. table 8-4. instruction description (continued) instruction description table 8-5. extest details instructions details ir input value 0000 (0x0) ir output value p00s dr size depending on boundary-scan chain, see bsdl-file. dr input value depending on boundary-scan chain, see bsdl-file. dr output value depending on boundary-scan chain, see bsdl-file.
74 42023e?sam?07/2013 atsam4l8/l4/l2 1. select the ir scan path. 2. in capture-ir: the ir output value is latched into the shift register. 3. in shift-ir: the instruction register is shifted by the tck input. 4. return to run-test/idle. 5. select the dr scan path. 6. in capture-dr: the data on the external pins are sampled into the boundary-scan chain. 7. in shift-dr: the boundary-scan chain is shifted by the tck input. 8. return to run-test/idle. 8.7.14.3 intest this instruction selects the boundary-scan chain as data register for testing internal logic in the device. the logic inputs are determined by the boundary-scan chain, and the logic outputs are captured by the boundary-scan chain. the device output pins are driven from the boundary-scan chain. starting in run-test/idle, the intest instruction is access ed the following way: 1. select the ir scan path. 2. in capture-ir: the ir output value is latched into the shift register. 3. in shift-ir: the instruction register is shifted by the tck input. 4. in update-ir: the data from the boundary-scan chain is applied to the internal logic inputs. 5. return to run-test/idle. 6. select the dr scan path. 7. in capture-dr: the data on the internal logic is sampled into the boundary-scan chain. 8. in shift-dr: the boundary-scan chain is shifted by the tck input. 9. in update-dr: the data from the boundary-scan chain is applied to internal logic inputs. 10. return to run-test/idle. table 8-6. sample_preload details instructions details ir input value 0001 (0x1) ir output value p00s dr size depending on boundary-scan chain, see bsdl-file. dr input value depending on boundary-scan chain, see bsdl-file. dr output value depending on boundary-scan chain, see bsdl-file. table 8-7. intest details instructions details ir input value 0100 (0x4) ir output value p001 dr size depending on boundary-scan chain, see bsdl-file. dr input value depending on boundary-scan chain, see bsdl-file. dr output value depending on boundary-scan chain, see bsdl-file.
75 42023e?sam?07/2013 atsam4l8/l4/l2 8.7.14.4 clamp this instruction selects the bypass register as data register. the device output pins are driven from the boundary-scan chain. starting in run-test/idle, the clamp instruction is acce ssed the following way: 1. select the ir scan path. 2. in capture-ir: the ir output value is latched into the shift register. 3. in shift-ir: the instruction register is shifted by the tck input. 4. in update-ir: the data from the boundary-scan chain is applied to the output pins. 5. return to run-test/idle. 6. select the dr scan path. 7. in capture-dr: a logic ?0? is loaded into the bypass register. 8. in shift-dr: data is scanned from tdi to tdo through the bypass register. 9. return to run-test/idle. table 8-8. clamp details instructions details ir input value 0101 (0x5) ir output value p00s dr size 1 dr input value x dr output value x
76 42023e?sam?07/2013 atsam4l8/l4/l2 8.8 system manager access port (smap) rev.: 1.0.0.0 8.8.1 features ? chip erase command and status ? cortex-m4 core reset source ? 32-bit cyclic redundancy check of an y memory accessible through the bus matrix ? unlimited flash user page read access ? chip identification register 8.8.2 overview the smap provides memory-related services and also cortex-m4 core reset control to a debug- ger through the debug port. this makes possible to halt the cpu and program the device after reset. 8.8.3 block diagram figure 8-7. smap block diagram 8.8.4 initializing the module the smap can be accessed only if the cpu clock is running and the swj-dp has been acti- vated by issuing a cdbgpwrup request. for more details, refer to the arm debug interface v5.1 architecture specification. then it must be enabled by writing a one to the en bit of the cr register (cr.en) before writing or reading other re gisters. if the smap is not enabled it will discard any read or write operation. 8.8.5 stopping the module to stop the module, the user must write a one to the dis bit of the cr register (cr.dis). all the user interface and internal re gisters will be cleared and the internal clock will be stopped. smap core reset request dap bus system bus matrix ahb chip_erase flash controller ahb smap ahb_master core dap interface reset controller pm cortex-m4 core reset system reset
77 42023e?sam?07/2013 atsam4l8/l4/l2 8.8.6 security considerations in protected state this module may access sensible information located in the device memories. to avoid any risk of sensible data extraction from the module registers, all operations are non interruptible except by a disable command triggered by writing a one to cr.dis. issuing this command clears all the interface and internal registers. some registers have some special protection: ? it is not possible to read or write the length register when the part is protected. ? in addition, when the part is protected and an operation is ongoing, it is not possible to read the addr and data registers. once an operation has started, the user has to wait until it has terminated by polling the done field in the status register (sr.done). 8.8.7 chip erase the chip erase operation consists in: 1. clearing all the volatile memories in the system 2. clearing the whole flash array 3. clearing the protected state no proprietary or sensitive information is left in volatile memories once the protected state is disabled. this feature is operated by writing a one to the ce bit of the control register (cr.ce). when the operation completes, sr.done is asserted. 8.8.8 cortex-m4 core reset source the smap processes the edp core hold reset requests (refer to section 8.7.8 ?smap core reset request source? on page 69 ). when requested, it instructs the power manager to hold the cortex-m4 core under reset. the smap can de-assert the core re set request if a one is written to the hold core reset bit in the status clear register (scr.hcr). this has t he effect of releasing the cpu from its reset state. to assert again this signal, a new rese t sequence with tck tied low must be issued. note that clearing hcr with this module is only possible when it is enabled, for more information refer to section 8.8.4 ?initializing the module? on page 76 . also note that asserting reset_n automatically clears hcr.
78 42023e?sam?07/2013 atsam4l8/l4/l2 8.8.9 unlimited flash user page read access the smap can access the user page even if the protected state is set. prior to operate such an access, the user should check that the module is not busy by checking that sr.state is equal to zerp. once the offset of the word to access inside the page is written in addr.addr, the read operation can be initiate d by writing a one in cr.fspr. the sr.state field will indicate the fspr state. addresses written to addr.addr must be world aligned. failing to do so will result in unpredictable behavior. the result can be read in the data register as soon as sr.done rises. the addr field is used as an of fset in the page, bits outside a page boundary will be silently discarded. the ad dr register is automatically in cremented at the end of the read operation making possible to dump consecutive words without writing the next offset into addr.addr. 8.8.10 32-bit cyclic redundancy check (crc) the smap unit provides support for calculati ng a cyclic redundancy check (crc) value for a memory area. the algorithm used is the industry standard crc32 algorithm using the generator polynomial 0xedb88320. 8.8.10.1 starting crc calculation to calculate crc for a memory rang e, the start address must be wr itten into the addr register, and the size of the memory range into the length register. both the start address and the length must be word aligned. the initial value used for the crc calculation must be written to the data register. this value will usually be 0xffffffff , but can be e.g. the result of a previous crc calcul ation if generat- ing a common crc of separate memory blocks. once completed, the calculated crc value can be read out of the data register. the read value must be inverted to match standard crc32 implementations, or kept non-inverted if used as starting point for subsequent crc calculations. if the device is in protected state, it is only poss ible to calculate the crc of the whole flash array. in most cases this area will be the entire onboard nonvolat ile memory. the addr, length, and data registers will be forced to predefined values once the crc operation is started, and user-written values are ignored. this allows the us er to verify the contents of a protected device. the actual test is started by writing a one in cr.crc. a running cr c operation can be can- celled by disabling the module (write a one in cr.dis). this has the effect of resetting the module. the module has to be restarted by issuing an enable command (write a one in cr.en). 8.8.10.2 interpreting the results the user should monitor the sr register (refer to section 8.8.11.2 ?status register? on page 81 ). when the operation is completed sr.done is set. then the sr.berr and sr.fail must be read to ensure that no bus error nor functional error occured.
79 42023e?sam?07/2013 atsam4l8/l4/l2 8.8.11 smap user interface note: 1. the reset value for this register is device specific. refe r to the module configuration sect ion at the end of this chapt er. 2. cr.mbist is ignored 3. scr.hcr is ignored 4. access is not allowed when an operation is ongoing table 8-9. smap register memory map offset register register name access (unprotected) access (protected) reset 0x0000 control register cr write-only write-only (partial) (2) 0x00000000 0x0004 status register sr read-only read-only 0x00000000 0x0008 status clear register scr w rite-only write-only (partial) (3) 0x00000000 0x000c address register addr read/write read/write (partial) (4) 0x00000000 0x0010 length register length read/write denied 0x00000000 0x0014 data register data read/write read/write (partial) (4) 0x00000000 0x0028 version register version read-only read-only - (1) 0x00f0 chip id register cidr read-only read-only - (1) 0x00f4 chip id extension regi ster exid read-only read-only - (1) 0x00fc ap identification register idr read-only read-only 0x003e0000
80 42023e?sam?07/2013 atsam4l8/l4/l2 8.8.11.1 control register name: cr access type: write-only offset: 0x00 reset value: 0x00000000 writing a zero to a bit in this register has no effect. ? ce: chip erase writing a one to this bit triggers the flash erase all (ea) operation which clears all volatile memories, the whole flash array , the general purpose fuses and the protected stat e. the status register done field indicates the completion of the operation. reading this bit always returns 0 ? fspr: flash user page read writing a one to this bit triggers a read operation in the user page. the word pointed by the addr register in the page is read and written to the data register. addr is post incremented a llowing a burst of reads without modifying addr. sr.done must be read high prior to reading the data register. reading this bit always returns 0 ? crc: cyclic redundancy code writing a one triggers a crc calculation over a memory area de fined by the addr and length registers. reading this bit always returns 0 note: this feature is restrict ed while in protected state ?dis: disable writing a one to this bit disables the module. disabling the module resets the whole module immediately. ? en: enable writing a one to this bit enables the module. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------- 76543210 - - - ce fspr crc dis en
81 42023e?sam?07/2013 atsam4l8/l4/l2 8.8.11.2 status register name: sr access type: read-only offset: 0x04 reset value: 0x00000000 ?state: state ? dbgp: debugger present 1: a debugger is present (tck falling edge detected) 0: no debugger is present ?prot: protected 1: the protected state is set. the only way to overcome this is to issue a chip erase command. 0: the protected state is not set ? en: enabled 1: the block is in ready for operation 0: the block is disabled. write operat ions are not possible until the block is enabled by writing a one in cr.en. ?lck: lock 1: an operation could not be performed because chip protected state is on. 0: no security issues have been detected sincle last clear of this bit ? fail: failure 1: the requested operation failed 0: no failure has been detected sincle last clear of this bit ? berr: bus error 1: a bus error occured due to the unability to access part of the requested memory area. 31 30 29 28 27 26 25 24 ----- state 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -----dbgpproten 76543210 - - - lck fail berr hcr done value state description 0 idle idle state 1 ce chip erase operation is ongoing 2 crc32 crc32 operation is ongoing 3 fspr flash user page read 4-7 - reserved
82 42023e?sam?07/2013 atsam4l8/l4/l2 0: no bus error has been detected sincle last clear of this bit ? hcr: hold core reset 1: the cortex-m4 core is held under reset 0: the cortex-m4 core is not held under reset ? done: operation done 1: at least one operation has terminated since last clear of this field 0: no operation has terminated since last clear of this field
83 42023e?sam?07/2013 atsam4l8/l4/l2 8.8.11.3 status clear register name: scr access type: write-only offset: 0x08 reset value: 0x00000000 writing a zero to a bit in this register has no effect. writing a one to a bit clears the corresponding sr bit note: writing a one to bit hcr while the chip is in protected state has no effect 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------- 76543210 - - - lck fail berr hcr done
84 42023e?sam?07/2013 atsam4l8/l4/l2 8.8.11.4 address register name: addr access type: read/write offset: 0x0c reset value: 0x00000000 ? addr: address value addess values are always world aligned 31 30 29 28 27 26 25 24 addr 23 22 21 20 19 18 17 16 addr 15 14 13 12 11 10 9 8 addr 76543210 addr - -
85 42023e?sam?07/2013 atsam4l8/l4/l2 8.8.11.5 length register name: length access type: read/write offset: 0x10 reset value: 0x00000000 ? length: length value, bits 1-0 are always zero 31 30 29 28 27 26 25 24 length 23 22 21 20 19 18 17 16 length 15 14 13 12 11 10 9 8 length 76543210 length - -
86 42023e?sam?07/2013 atsam4l8/l4/l2 8.8.11.6 data register name: data access type: read/write offset: 0x14 reset value: 0x00000000 ? data: generic data register 31 30 29 28 27 26 25 24 data 23 22 21 20 19 18 17 16 data 15 14 13 12 11 10 9 8 data 76543210 data
87 42023e?sam?07/2013 atsam4l8/l4/l2 8.8.11.7 module version name: version access type: read-only offset: 0x28 reset value: - ? variant: variant number reserved. no functionality associated. ? version: version number version number of the module. no functionality associated. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 ---- variant 15 14 13 12 11 10 9 8 ---- version 76543210 version
88 42023e?sam?07/2013 atsam4l8/l4/l2 8.8.11.8 chip identification register name: cidr access type: read-only offset: 0xf0 reset value: - note: refer to section chipid for more information on this register. 31 30 29 28 27 26 25 24 ext nvptyp arch 23 22 21 20 19 18 17 16 arch sramsiz 15 14 13 12 11 10 9 8 nvpsiz2 nvpsiz 76543210 eproc version
89 42023e?sam?07/2013 atsam4l8/l4/l2 8.8.11.9 chip identification extension register name: exid access type: read-only offset: 0xf4 reset value: - note: refer to section chipid for more information on this register. 31 30 29 28 27 26 25 24 exid 23 22 21 20 19 18 17 16 exid 15 14 13 12 11 10 9 8 exid 76543210 exid
90 42023e?sam?07/2013 atsam4l8/l4/l2 8.8.11.10 identification register name: idr access type: read-only offset: 0xfc reset value: - ? revision: revision ? cc: jep-106 continuation code atmel continuation code is 0x0 ? ic: jep-106 identity code atmel identification code is 0x1f ? clss: class 0: this ap is not a memory access port 1: this ap is a memory access port ? apid: ap identification ? apidv: ap identification variant for more information about this register, refer to the arm debug interface v5.1 architecture specification document. 31 30 29 28 27 26 25 24 revision cc 23 22 21 20 19 18 17 16 ic clss 15 14 13 12 11 10 9 8 reserved 76543210 apid apidv
91 42023e?sam?07/2013 atsam4l8/l4/l2 8.9 ahb-ap access port the ahb-ap is a memory access port (mem-ap) as defined in the arm debug interface v5 architecture specification. the ahb-ap provides access to all memory and registers in the sys- tem, including processor registers through the sy stem control space (scs). system access is independent of the processor status. either sw-d p or swj-dp is used to access the ahb-ap. the ahb-ap is a master into the bus matrix. transactions are made using the ahb-ap pro- grammers model (refer to the arm cortex-m4 technical reference manual), which generates ahb-lite transactions into the bus matrix. the ahb-ap does not perform back-to-back transac- tions on the bus, so all transactions are non-sequential. the ahb-ap can perform unaligned and bit-band transactions. the bus matrix handles these. the ahb-ap transactions are not subject to mpu lookups. ahb-ap transactions bypass the fpb, and so the fpb cannot remap ahb-ap transactions. ahb-ap transactions are little-endian. note that while an external reset is applied, ahb-ap accesses are not possible. in addition, access is denied when the protected state is set. in order to discard the protected state, a chip erase operation is necessary.
92 42023e?sam?07/2013 atsam4l8/l4/l2 8.10 available features in protected state table 8-10. features availablility wh en in protected state feature provider availability when protected hot plugging edp yes system bus r/w access ahb-ap no flash user page read access smap yes core hold reset clear from the smap interface smap no crc32 of any memory accessible through the bus matrix sm ap restricted (limited to the entire flash array) chip erase smap yes idcode edp yes fpb, dwt & itm cortex-m4 no
93 42023e?sam?07/2013 atsam4l8/l4/l2 8.11 functional description 8.11.1 debug environment figure 8-8 shows a complete debug environment example. the swj-dp interface is used for standard debugging functions, such as downloading code and single-stepping through the pro- gram and viewing core and peripheral registers. figure 8-8. application debug environment example 8.11.2 test environment figure 8-9 shows a test environment example (jtag boundary scan). test vectors are sent and interpreted by the tester. in this example, the ?board in test? is designed using a number of jtag-compliant devices. these devices can be connected to form a single scan chain. s am4 ho s t de bu gger pc s am4- bas ed applic a tion bo a rd s wj-dp connector s wj-dp em u l a tor/pro b e
94 42023e?sam?07/2013 atsam4l8/l4/l2 figure 8-9. application test environment example 8.11.3 how to initialize test and debug features to enable the jtag pins a falling edge event must be detected on the tck pin at any time after the reset_n pin is released. in some specific cases, the user would prevent system from running code after reset is released. this is done by holding low th e tck pin when the reset_n is released. this makes the smap assert the core_hold_reset signal that hold the cortex-m4 core under reset. to make the cpu run again, the user should clear the chr bit in the status register (sr.chr) to de-assert the core_hold_reset signal. independent of the initial state of the tap controller, the test-logic-reset state can always be entered by holding tms high for 5 tck clock periods. this sequence should always be applied at the start of a jtag session and after enabling the jtag pins to bring the tap controller in to a defined state before applying jtag commands. applying a zero on tms for 1 tck period brings the tap controller to the run-test/idle state, which is the starting point for jtag operations. 8.11.4 how to disable test and debug features to disable the jtag pins the tck pin must be held high while reset _n pin is released. 8.11.5 typical jtag sequence assuming run-test/idle is the present state, a typical scenario for using the jtag interface is: 8.11.5.1 scanning in jtag instruction at the tms input, apply the sequence 1, 1, 0, 0 at the rising edges of tck to enter the shift instruction register - shift-ir state. while in this state, shift the 4 bits of the jtag instructions into the jtag instruction register from the tdi input at the rising edge of tck. the tms input must be held low during input of the 4 lsbs in order to remain in the shift-ir state. the jtag instruction selects a particular data register as path between tdi and tdo and controls the cir- cuitry surrounding the selected data register. chip 2 chip n chip 1 s am4 s am4- bas ed applic a tion bo a rd in te s t jtag connector te s ter te s t ad a ptor jtag pro b e
95 42023e?sam?07/2013 atsam4l8/l4/l2 apply the tms sequence 1, 1, 0 to re-enter the run-test/idle state. the instruction is latched onto the parallel output from the shift register path in the update-ir state. the exit-ir, pause-ir, and exit2-ir states are only used for navigating the state machine. figure 8-10. scanning in jtag instruction 8.11.5.2 scanning in/out data at the tms input, apply the sequence 1, 0, 0 at the rising edges of tck to enter the shift data register - shift-dr state. while in this state, upload the selected data register (selected by the present jtag instruction in the jtag instruction register) from the tdi input at the rising edge of tck. in order to remain in the shift-dr state, the tms input must be held low. while the data register is shifted in from the tdi pin, the parallel inputs to the data register captured in the capture-dr state is shifted out on the tdo pin. apply the tms sequence 1, 1, 0 to re-enter the run-test/idle state. if the selected data register has a latched parallel-output, the latching takes place in the update-dr state. the exit-dr, pause-dr, and exit2-dr states are only used for navigating the state machine. as shown in the state diagram, the run-test/idle state need not be entered between selecting jtag instruction and using data registers. 8.11.6 boundary-scan the boundary-scan chain ha s the capability of driving and obser ving the logic levels on the dig- ital i/o pins, as well as the boundary between di gital and analog logic for analog circuitry having off-chip connections. at system level, all ics having jtag capabilities ar e connected serially by the tdi/tdo signals to form a long shift register. an external controller sets up the devices to drive values at their output pins, and observe the input values received from other devices. the controller compares the received data with the expected result. in this way, boundary-scan pro- vides a mechanism for testing interconnections and integrity of components on printed circuits boards by using the 4 tap signals only. the four ieee 1149.1 defined mandatory jtag in structions idcode, bypass, sample/pre- load, and extest can be used for testing the printed circuit board. initial scanning of the data register path will show th e id-code of the device, sinc e idcode is the default jtag instruction. it may be desirable to have the device in reset during test mode. if not reset, inputs to the device may be determined by the scan operations, and the internal software may be in an undetermined state when exiting the test mode. entering reset, the outputs of any port pin will instantly enter the high impedance state, making the highz instruction redundant. if needed, the bypass instruction can be issued to make the shortest possible scan chain through the device. the device c an be set in the reset state by pu lling the external reset_n pin low. the extest instruction is used for sampling external pins and loading output pins with data. the data from the output latch will be driven out on the pins as soon as the extest instruction is loaded into the jtag ir-register. therefore, the sample/preload should also be used for setting initial values to the scan ring, to avoid damaging the board when issuing the extest tck tap state tlr rti seldr selir capir shir ex1ir updir rti tms tdi instruction tdo impldefined
96 42023e?sam?07/2013 atsam4l8/l4/l2 instruction for the first time. sample/preload c an also be used for taking a snapshot of the external pins during normal operation of the part. when using the jtag interface for boundary-sc an, the jtag tck clock is independent of the internal chip clock, whic h is not required to run. note: for pins connected to 5v lines care should be taken to not drive the pins to a logic one using boundary scan, as this will cr eate a current flowing from the 3,3v driver to the 5v pullup on the line. optionally a series resistor can be added between the line and the pin to reduce the current. 8.11.7 flash programming typical procedure flash programming is performed by operating fl ash controller commands. the flash controller is connected to the syst em bus matrix and is then contro llable from the ahp-ap. the ahb-ap cannot write the flash page buffer while the core_hold_reset is asserted. the ahb-ap cannot be accessed when the device is in protected state. it is important to ensure that the cpu is halted prior to operating any flash programming operation to prevent it from corrupting the sys- tem configuration. the recommended sequence is shown below: 1. at power up, reset_n is driven low by a debugger. the on-chip regulator holds the system in a por state until the input supply is above the por threshold. the system continues to be held in this static state until the internally regulated supplies have reached a safe operating. 2. pm starts, clocks are switched to the slow clock (core clock, system clock, flash clock, and any bus clocks that do not have clock gate control). internal resets are maintained due to the external reset. ? the debug port (dp) and access ports (ap) receives a clock and leave the reset state, 3. the debugger maintains a low level on tck and release reset_n. ? the smap asserts the core_hold_reset signal 4. the cortex-m4 core remains in reset stat e, meanwhile the rest of the system is released. 5. the debugger then configures the nvic to catch the cortex-m4 core reset vector fetch. for more information on how to program the nvic, refer to the armv7-m architecture reference manual. 6. the debugger writes a one in the smap scr.hcr to release the cortex-m4 core reset to make the system bus matrix accessible from the ahb-ap. 7. the cortex-m4 core initializes the sp, then read the exception vector and stalls 8. programming is available through the ahb-ap 9. after operation is co mpleted, the chip can be restarte d either by asserting reset_n or switching power off/on or clearing scr.hcr. make sure that the tck pin is high when releasing reset_n not to halt the core.
97 42023e?sam?07/2013 atsam4l8/l4/l2 8.11.8 chip erase typical procedure the chip erase operation is triggered by writing a one in the ce bit in the control register (cr.ce). this clears first all volatile memories in the system and second the whole flash array. note that the user page is not erased in this process. to ensure that the chip erase operation is completed, check the done bit in the status register (sr.done). also note that the chip erase operation depends on clocks and power management features that can be altered by the cpu. it is important to ensure that it is stopped. the recommended sequence is shown below: 1. at power up, reset_n is driven low by a debugger. the on-chip regulator holds the system in a por state until the input supply is above the por threshold. the system continues to be held in this static state until the internally regulated supplies have reached a safe operating. 2. pm starts, clocks are switched to the slow clock (core clock, system clock, flash clock, and any bus clocks that do not have clock gate control). internal resets are maintained due to the external reset. ? the debug port and access ports receives a clock and leave the reset state 3. the debugger maintains a low level on tck and release reset_n. ? the smap asserts the core_hold_reset signal 4. the cortex-m4 core remains in reset stat e, meanwhile the rest of the system is released. 5. the chip erase operation can be performed by issuing the smap chip erase com- mand. in this case: ? volatile memories are cleared first ? followed by the clearing of the flash array ? followed by the clearing of the protected state 6. after operation is completed, the device must be restarted by either controling reset_n or switching power off/on. make sure that the tck pin is high when releas- ing reset_n not to halt the core. 8.11.9 setting the protected state this is done by issuing a specific flash controller command, for more information, refer to sec- tion 14. ?flash controller (flashcalw)? on page 262 and to section 8.11.7 ?flash programming typical procedure? on page 96 . the protected state is defined by a highly secure flash builtin mechanism. note that for this programmation to propagate, it is required to reset the device.
page 42023e?sam?07/2013 atsam4l8/l4/l2 9. chip identifier (chipid) 9.1 description chip identifier registers permit recognition of the device and its revision. these registers provide the sizes and types of the on-chip memories, as well as the set of embedded peripherals. two chip identifier registers are embedded: ci dr (chip id register) and exid (extension id). both registers contain a hard-wired value that is read-only. the first register contains the follow- ing fields: ? ext - shows the use of the extension identifier register ? nvptyp and nvpsiz - identifies the type of embedded non-volatile memory and its size ? arch - identifies the set of embedded peripherals ? sramsiz - indicates the size of the embedded sram ? eproc - indicates the embedded arm processor ? version - gives the revision of the silicon the second register is device-dependent and reads 0 if the bit ext is 0. 9.2 embedded characteristics ? chip id registers ? identification of the device revision, sizes of the embedded memories, set of peripherals, embedded processor table 9-1. atsam4l chip ids register chip name family flash/ram pack age chipid_cidr chipid_exid atsam4lc8c (rev a) atsam4lc 512k/64k 100-pin 0xab0b0ae0 0x1400000f atsam4lc4c (rev a) atsam4lc 256k/32k 100-pin 0xab0a09e0 0x0400000f atsam4lc2c(rev a) atsam4lc 128k/32k 100-pin 0xab0a07e0 0x0400000f atsam4lc8b (rev a) atsam4lc 512k/64k 64-pins 0xab0b0ae0 0x1300000f atsam4lc4b (rev a) atsam4lc 256k/32k 64-pins 0xab0a09e0 0x0300000f atsam4lc2b (rev a) atsam4lc 128k/32k 64-pins 0xab0a07e0 0x0300000f atsam4lc8a (rev a) atsam4lc 512k/64k 48-pins 0xab0b0ae0 0x1200000f atsam4lc4a (rev a) atsam4lc 256k/32k 48-pins 0xab0a09e0 0x0200000f atsam4lc2a (rev a) atsam4lc 128k/32k 48-pins 0xab0a07e0 0x0200000f atsam4ls8c (rev a) atsam4ls 512k/64k 100-pins 0xab0b0ae0 0x14000002 atsam4ls4c (rev a) atsam4ls 256k/32k 100-pins 0xab0a09e0 0x04000002 atsam4ls2c (rev a) atsam4ls 128k/32k 100-pins 0xab0a07e0 0x04000002 atsam4ls8b (rev a) atsam4ls 512k/64k 64-pins 0xab0b0ae0 0x13000002 atsam4ls4b (rev a) atsam4ls 256k/32k 64-pins 0xab0a09e0 0x03000002 atsam4ls2b (rev a) atsam4ls 128k/32k 64-pins 0xab0a07e0 0x03000002
page 42023e?sam?07/2013 atsam4l8/l4/l2 atsam4ls8a (rev a) atsam4ls 512k/64k 48-pins 0xab0b0ae0 0x12000002 atsam4ls4a (rev a) atsam4ls 256k/32k 48-pins 0xab0a09e0 0x02000002 atsam4ls2a (rev a) atsam4ls 128k/32k 48-pins 0xab0a07e0 0x02000002 table 9-1. atsam4l chip ids register chip name family flash/ram pack age chipid_cidr chipid_exid
page 42023e?sam?07/2013 atsam4l8/l4/l2 9.3 user interface table 9-2. chipid register memory map offset register register name access reset 0x0 chip id register cidr read-only ? 0x4 chip id extension register exid read-only ?
page 42023e?sam?07/2013 atsam4l8/l4/l2 9.3.1 chip id register name: cidr access: read-only offset: 0x0 reset value: - ? ext: extension flag 0 = chip id has a single register definition without extension 1 = an extended chip id exists. ? nvptyp: nonvolatile program memory type 31 30 29 28 27 26 25 24 ext nvptyp arch[7:4] 23 22 21 20 19 18 17 16 arch[3:0] sramsiz 15 14 13 12 11 10 9 8 nvpsiz2 nvpsiz 76543210 eproc version value name description 0rom rom 1 romless romless or on-chip flash 4 sram sram emulating rom 2 flash embedded flash memory 3 rom_flash rom and embedded flash memory nvpsiz is rom size nvpsiz2 is flash size
page 42023e?sam?07/2013 atsam4l8/l4/l2 ? arch: architecture identifier value name description 0x19 at91sam9xx at91sam9xx series 0x29 at91sam9xexx at91sam9xexx series 0x34 at91x34 at91x34 series 0x37 cap7 cap7 series 0x39 cap9 cap9 series 0x3b cap11 cap11 series 0x40 at91x40 at91x40 series 0x42 at91x42 at91x42 series 0x55 at91x55 at91x55 series 0x60 at91sam7axx at91sam7axx series 0x61 at91sam7aqxx at91sam7aqxx series 0x63 at91x63 at91x63 series 0x70 at91sam7sxx at91sam7sxx series 0x71 at91sam7xcxx at91sam7xcxx series 0x72 at91sam7sexx at91sam7sexx series 0x73 at91sam7lxx at91sam7lxx series 0x75 at91sam7xxx at91sam7xxx series 0x76 at91sam7slxx at91sam7slxx series 0x80 sam3uxc sam3uxc series (100-pin version) 0x81 sam3uxe sam3uxe series (144-pin version) 0x83 sam3axc sam3axc series (100-pin version) 0x83 sam4axc sam4axc series (100-pin version) 0x84 sam3xxc sam3xxc series (100-pin version) 0x84 sam4xxc sam4xxc series (100-pin version) 0x85 sam3xxe sam3xxe series (144-pin version) 0x85 sam4xxe sam4xxe series (144-pin version) 0x86 sam3xxg sam3xxg series (208/217-pin version) 0x86 sam4xxg sam4xxg series (208/217-pin version) 0x88 sam3sxa sam3sxaseries (48-pin version) 0x88 sam4sxa sam4sxa series (48-pin version) 0x89 sam3sxb sam3sxb series (64-pin version) 0x89 sam4sxb sam4sxb series (64-pin version) 0x8a sam3sxc sam3sxc series (100-pin version) 0x8a sam4sxc sam4sxc series (100-pin version) 0x92 at91x92 at91x92 series
page 42023e?sam?07/2013 atsam4l8/l4/l2 ? sramsiz: internal sram size 0x93 sam3nxa sam3nxa series (48-pin version) 0x94 sam3nxb sam3nxb series (64-pin version) 0x95 sam3nxc sam3nxc series (100-pin version) 0x99 sam3sdxb sam3sdxb series (64-pin version) 0x9a sam3sdxc sam3sdxc series (100-pin version) 0xa5 sam5a sam5a 0xb0 sam4l sam4lxx series 0xf0 at75cxx at75cxx series value name description 048k 48k bytes 11k 1k bytes 22k 2k bytes 36k 6k bytes 424k 24k bytes 54k 4k bytes 680k 80k bytes 7 160k 160k bytes 88k 8k bytes 916k 16k bytes 10 32k 32k bytes 11 64k 64k bytes 12 128k 128k bytes 13 256k 256k bytes 14 96k 96k bytes 15 512k 512k bytes value name description
page 42023e?sam?07/2013 atsam4l8/l4/l2 ? nvpsiz2: second nonvolatile program memory size ? eproc: embedded processor ? nvpsiz: nonvolatile program memory size value name description 0 none none 18k 8k bytes 216k 16k bytes 332k 32k bytes 4 reserved 564k 64k bytes 6 reserved 7 128k 128k bytes 8 reserved 9 256k 256k bytes 10 512k 512k bytes 11 reserved 12 1024k 1024k bytes 13 reserved 14 2048k 2048k bytes 15 reserved value name description 1 arm946es arm946es 2 arm7tdmi arm7tdmi 3 cm3 cortex-m3 4 arm920t arm920t 5 arm926ejs arm926ejs 6ca5 cortex-a5 7 cm4 cortex-m4 value name description 0none none 18k 8k bytes 2 16k 16k bytes 3 32k 32k bytes
page 42023e?sam?07/2013 atsam4l8/l4/l2 ? version: version of the device current version of the device. 4reserved 5 64k 64k bytes 6reserved 7 128k 128k bytes 8reserved 9 256k 256k bytes 10 512k 512k bytes 11 reserved 12 1024k 1024k bytes 13 reserved 14 2048k 2048k bytes 15 reserved value name description
page 42023e?sam?07/2013 atsam4l8/l4/l2 9.3.2 extension register name: exid access: read-only offset: 0x4 reset value: - ? package: package type ? lcd: lcd option 31 30 29 28 27 26 25 24 ----- package 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------- 76543210 - - - - lcd usbfull usb aes value description 0 24-pin package 1 32-pin package 2 48-pin package 3 64-pin package 4 100-pin package 5 144-pin package 6 reserved 7 value description 0 lcd is not implemented 1 lcd is implemented
page 42023e?sam?07/2013 atsam4l8/l4/l2 ? usb: usb option ? usbfull: usb configuration ? aes: aes option value description 0 usb is not implemented 1 usb is implemented value description 0 usb is device-only 1 usb is device and host value description 0 aes is not implemented 1 aes is implemented
108 42023e?sam?07/2013 atsam4l8/l4/l2 10. power manager (pm) rev: 4.4.1.1 10.1 features ? generates clocks and resets for digital logic ? on-the-fly frequency change of cpu, hsb and pbx clocks ? module-level clock gating through maskable peripheral clocks ? controls resets of the device 10.2 overview the power manager (pm) provides synchronous clocks used to clock the main digital logic in the device, namely the cpu, and the modules and peripherals connected to the high speed bus (ahb) and the peripheral buses (apbx). the synchronous clocks are divided into a number of clock domains, one for the cpu and ahb and one for each apbx. the clocks can run at different speeds, so the user can save power by running peripherals at a relatively low clock, while maintaining a high cpu performance. addi- tionally, the clocks can be independently cha nged on-the-fly, without halting any peripherals. this enables the user to adjust the speed of the cpu and memories to the dynamic load of the application, without disturbing or re-configuring active peripherals. each module also has a sep- arate clock, enabling the user to switch off the clock for inactive modules, to save further power. additionally, clocks and oscillators can be auto matically switched off du ring power save mode periods by using the power save mode feature of the backup power manager module (bpm). the power manager also contains a reset contro ller, which collects all possible reset sources, generates hard and soft resets, and allows the reset source to be identified by software. 10.3 block diagram figure 10-1. pm block diagram pm synchronous clock generator reset controller resets synchronous clocks cpu, ahb, apbx external reset pin scif/ bscif power save mode apb bus user interface nvic reset sources bpm main clock sources
109 42023e?sam?07/2013 atsam4l8/l4/l2 10.4 i/o lines description 10.5 product dependencies 10.5.1 interrupt the pm interrupt line is connected to one of the internal sources of the nvic. using the pm interrupt requires the nvic to be programmed first. 10.5.2 clock implementation in atsam4l, the ahb shares th e source clock with the cpu. the clock for the pm bus interface (clk_pm) is generated by the power manager. this clock is enabled at reset, and can be disabled in the power manager. if disabled, it can only be re- enabled by a reset. 10.6 functional description 10.6.1 synchronous clocks the system rc oscillator (rcsys) or a set of other clock sources provide the source for the main clock, which is the common root for the synchronous clocks for the cpu, ahb and apbx modules. for details about the other main clock sour ces, refer to the register description of the main clock control register (m cctrl). the main clock is divided by an 8-bit prescaler, and each of these synchronous clocks can run from any tapping of th is prescaler, or the undivided main clock, as long as f cpu f apbx, . the synchronous clock source can be changed on-the fly, responding to varying load in the application. the clocks for each module in each synchronous clock domain can be individually masked, to av oid power consumption in inactive modules. depending on the power save mode, some clock domains can be cut. table 10-1. i/o lines description name description type active level reset_n reset input low
110 42023e?sam?07/2013 atsam4l8/l4/l2 figure 10-2. synchronous clock generation 10.6.1.1 selecting the main clock source the common main clock can be connected to rcsys or a set of other cl ock sources. for details about the other main clock sources, refer to section 10.7.1 ?main clock control? on page 116 . by default, the main clock will be connected to rcsys. the user can c onnect the main clock to an other source by writing the mcsel field in the mcctrl register. this must only be done after that unit has been enabled and is ready, otherwis e a deadlock will occur. care should also be taken that the new frequency of the synchronous clocks does not exceed the maximum fre- quency for each clock domain. 10.6.1.2 selecting synchronous clock division ratio the main clock feeds an 8-bit prescaler, which can be used to generate the synchronous clocks. by default, the synchronous clocks run on the undivided main clock. the user can select a pres- caler division for the cpu clock by writing cp udiv in cpusel register to one and cpusel in cpusel register to the value, resulting in a cpu clock frequency: f cpu = f main / 2 (cpusel+1) similarly, the clock for the apbx can be divided by writing their respective registers. to ensure correct operation, frequencies must be selected so that f cpu f apbx . also, frequencies must never exceed the specified maximum frequency for each clock domain. cpusel and pbxsel can be written without halting or disabling peripheral modules. writing cpusel and pbxsel allows a new clock setting to be written to all synchronous clocks at the same time. it is possible to keep one or more clocks unchanged by writing a one to the registers. this way, it is possible to, e.g., scale cpu and speed according to the required performance, while keeping the apbx frequency constant. for modules connected to the ahb bus, the apb clock frequency must be set to the same fre- quency as the cpu clock. mask prescaler main clock sources mcsel 0 1 cpusel cpudiv main clock bpm cpumask cpu clocks ahb clocks apbx clocks power save mode
111 42023e?sam?07/2013 atsam4l8/l4/l2 10.6.1.3 clock ready flag there is a slight delay from cpusel and pbx sel being written to the new clock setting taking effect. during this interval, the clock ready bi t in the status register (sr.ckrdy) will read as zero. when the clock settings change is complet ed, the bit will read as one. the clock select registers (cpusel, pbxsel) must not be writte n to while sr.ckrdy is zero, or the system may become unstable or hang. the clock ready bit in the interrupt status regi ster (isr.ckrdy) is set on a sr.ckrdy zero- to-one transition. if the clock ready bit in the interrupt mask register (imr.ckrdy) is set, an interrupt request is generated. imr.ckrdy is set by writing a one to the corresponding bit in the interrupt enable register (ier.ckrdy). 10.6.2 peripheral clock masking by default, only the necessary clocks are enabled (see the reset value of the mask registers). it is possible to disable or enable the clock for a module in the cpu, or apbx clock domain by writing the corresponding bit in the clock mask register (cpu/hsb/pbx) to zero or one. when a module is not clocked, it will cease operation, and its registers cannot be read or written. the module can be re-enabled later by writing the corresponding mask bit to one. a module may be connected to several clock domains, in which case it will have several mask bits. the maskable module clocks table contains a list of implemented maskable clocks. 10.6.2.1 cautionary note note that clocks should only be switched off if it is certain that the module will not be used. switching off the clock for the flash controller will cause a problem if the cpu needs to read from the flash. switching off the clock to the power manager (pm), which contains the mask registers, or the corresponding apbx bridge, will make it impossible to write the mask registers again. in this case, they can only be re-enabled by a system reset. 10.6.2.2 sleepwalking ? in all power save modes except in backup mode, where the apbx clocks are stopped, the device can wake pa rtially up if a apbx module asynchronously discovers that it needs its clock. only the requeste d clocks and clock sources needed will be started, and all other clocks will be masked to zero. e.g. if the main clock source is osc0, only osc0 will be started even if other clock sources were enabled in run mode. also generic clocks can be started in a similar way. the state where only requested clocks are running is referred to as sleepwalking. the time spent to start the requested clock is mostly limited by the startup time of the given clock source. this allows apbx modules to handle in coming requests, while still keeping the power consumption at a minimum. when the device is sleepwalking any asynchronous wake up sources can wake up the device at any time without stopping the requested apbx clock. all requests to start clocks can be masked by writing to the peripheral power control register (ppcr), all requests are enabled at reset. during sleepwalking the nvic cloc k will be running except in backup mode. if an interrupt is pending when entering sl eepwalking, this will wake up the whole device.
112 42023e?sam?07/2013 atsam4l8/l4/l2 10.6.3 speeding-up sleep modes wake up times the normal way for the power manager to enter wait mode involves automatically switching the main clock to rcsys before stopping all oscilla tors. during wake-up, t he main clock is auto- matically switched back from rcsys to the oscill ator selected before the wfi instruction was executed. the delay ne eded to switch to/from the rcsys os cillator is around three rcsys clock cycles, plus oscillator startup times when waking up. it is possible to speed-up the enter/wake-up times for the wait modes by disabling the auto- matic switch to rcsys. this is only useful if a high fr equency oscillator with a very fast startup time is used. the user has to select the main clock source by writing a one to the corresponding bit in the fastsleep register. the device will not wa ke up correctly if the right oscillator in the fastsleep register is not selected. to have a fast wakeup time in wait and retention power save mode, refer to section 6.1.4 ?wakeup time? on page 55 10.6.4 divided apb clocks the clock generator in the powe r manager provides di vided apbx clocks fo r use by peripherals that require a prescaled apbx clock. this is described in the documentation for the relevant modules. the divided clocks are directly maskable, and are stopped in power save modes where the apbx clocks are stopped. 10.6.5 reset controller the reset controller collects the various reset sources and generates resets for the device. the device contains a power-on detector, which keeps the system reset until power is stable. this eliminates the need for external reset circuitry to guarantee stable operation when powering up the device. it is also possible to reset the device by pulling the reset_n pin low. this pin has an internal pull-up, and does not need to be driven externally during normal operation. table 10-2 on page 112 lists these and other reset sources supported by the reset controller. table 10-2. reset description reset source description por18 reset supply voltage below the 1.8v power-on reset detector threshold voltage external reset reset_n pin asserted bod18 reset supply voltage on vddcore below the 1.8v brownout reset detector threshold voltage bod33 reset supply voltage on i/o below the 3.3v brownout reset detector threshold voltage por33 reset supply voltage on i/o below the 3.3 v power-on reset detector threshold voltage watchdog timer see watchdog timer documentation backup reset reset from backup mode when a wake up source occurs ocd reset see on-chip debug and test chapter
113 42023e?sam?07/2013 atsam4l8/l4/l2 depending on the reset source, when a reset occurs, some parts of the device are not always reset. only the power on reset (por) will force a whole device reset. refer to the table in the module configuration section at the end of this chapter for further details. the latest reset cause can be read in the rcause register, and can be read during the applications boot sequence in order to determine proper action. the table below lists parts of the device that are reset, depending on the reset type. the cause of the last reset can be read from the rcause r egister. this register contains one bit for each reset source, and can be read during the boot sequence of an application. 10.6.6 clock failure detector this mechanism allo ws switching the main cl ock to the safe rcsys clock, when the main clock source is considered off. this may happen when a external crystal is selected as the clock source of the main clock but the crystal is not mounted on the board. the mechanism is to detect, during a rcsys period, at least one ri sing edge of the main clock. if no rising edge is seen the clock is considered failed. example: * rcsys = 115khz => failure detected if the main clock is < 115 khz as soon as the dete ctor is enabled, the clock failure dete ctor will monitor the divided main clock. note that the detector does not monitor if the rcsys is the source of the main clock, or if the main clock is temporarily not available (startup-tim e after a wake-up, switching timing etc.), or in sleep mode where the main clock is driven by the rcsys (sleep mode level 3). when a clock failure is detected, the ma in clock automatically switches to the rcsys clock and the cfd interrupt is generated if enabled. the mcctrl register that select s the source clock of the main clock is changed by hardware to indicate that the main clock comes from rcsys. 10.6.7 interrupts the pm has a number of interrupts: ? ae - access error, ? a lock protected register is written to without first being unlocked. ? ckrdy - clock ready: ? new clock select settings in the cpusel /pbxsel registers have taken effect. (a zero-to-one transition on sr.ckrdy is detected). ? cfd - clock failure detected: ? the system detects that the main clock is not running. ? wake - asynchronous wake detected: ? an asynchronous wakeup from a peripheral is detetcted. the interrupt status register contains one bit fo r each interrupt source. a bit in this register is set on a zero-to-one transition of the correspond ing bit in the status re gister (sr), and cleared by writing a one to the corresponding bit in the interrupt clear register (icr). the interrupt sources will generate an interrupt re quest if the corresponding bit in the interrupt mask register is set. the interrupt sources are ored together to form one interrupt request. the power man-
114 42023e?sam?07/2013 atsam4l8/l4/l2 ager will generate an interrupt request if at least one of the bits in the interrupt mask register (imr) is set. bits in imr are set by writing a one to the corresponding bit in the interrupt enable register (ier), and cleared by writing a one to the corresponding bit in the interrupt disable register (idr). the interrupt request remains active until the corresponding bit in the interrupt status register (isr) is cleared by writing a one to the corresponding bit in the interrupt clear register (icr). because all the interrupt sour ces are ored together, the interrupt request from the power manager will remain active un til all the bits in isr are cleared.
115 42023e?sam?07/2013 atsam4l8/l4/l2 10.7 user interface note: 1. the reset value is device specific. refer to the m odule configuration section at the end of this chapter. 2. latest reset source. 3. latest wake source. table 10-3. pm register memory map offset register register name access reset 0x000 main clock control mcctrl read/write 0x00000000 0x004 cpu clock select cpusel read/write 0x00000000 0x00c pba clock select pbas el read/write 0x00000000 0x010 pbb clock select pbbs el read/write 0x00000000 0x014 pbc clock select pbcsel read/write 0x00000000 0x018 pbd clock select pbdsel read/write 0x00000000 0x020 cpu mask cpumask read/write 0x00000001 0x024 hsb mask hsbmask read/write 0x000001e2 0x028 pba mask pbamask r ead/write 0x00000000 0x02c pbb mask pbbmask read/write 0x00000001 0x030 pbc mask pbcmask read/write 0x0000001f 0x034 pbd mask pbdmask read/write 0x0000003f 0x040 pba divided mask pbadiv mask read/write 0x00000000 0x054 clock failure detector control cfdctrl read/write 0x00000000 0x058 unlock register unlock write-only 0x00000000 0x0c0 interrupt enable register ier write-only 0x00000000 0x0c4 interrupt disable register idr write-only 0x00000000 0x0c8 interrupt mask register imr read-only 0x00000000 0x0cc interrupt status register isr read-only 0x00000000 0x0d0 interrupt clear register icr write-only 0x00000000 0x0d4 status register sr read-only 0x00000000 0x160 peripheral power control register ppcr read/write 0x000001fe 0x180 reset cause register rcause read-only - (2) 0x184 wake cause register wcause read-only - (3) 0x188 asynchronous wake enable awen read/write 0x00000000 0x18c protection control register protctrl read/write 0x00000000 0x194 fast sleep register fastsleep read/write 0x00000000 0x3f8 configuration register config read-only 0x0000000f 0x3fc version register version read-only - (1)
116 42023e?sam?07/2013 atsam4l8/l4/l2 10.7.1 main clock control name: mcctrl access type: read/write offset: 0x000 reset value: 0x00000000 ? mcsel: main clock select note: 1. if the 80mhz rc oscillator is selected as main clock source , it must be divided by at least 2 before being used as clock source for the cpu. this division is selected by writing to the cpusel and cpudiv bits in the cpusel register, before switching to rc80m as main clock source. note that this register is protected by a lock. to write to th is register the unlock register has to be written first. refer to section 10.7.7 ?pm unlock register? on page 123 for details. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------- 76543210 ----- mcsel table 10-4. main clocks in atsam4l. mcsel[2:0] main clock source 0 system rc oscillator (rcsys) 1 oscillator0 (osc0) 2pll 3dfll 4 80mhz rc oscillator (rc80m) (1) 5 4/8/12 mhz rc oscillator (rcfast) 6 1 mhz rc oscillator (rc1m) 7 reserved
117 42023e?sam?07/2013 atsam4l8/l4/l2 10.7.2 cpu clock select name: cpusel access type: read/write offset: 0x004 reset value: 0x00000000 ? cpudiv, cpusel: cpu di vision and clock select cpudiv = 0: cpu clock equals main clock. cpudiv = 1: cpu clock equals main clock divided by 2 (cpusel+1) . note that if cpudiv is written to 0, cpusel should also be written to 0 to ensure correct operation. also note that writing this register clears sr.ckrdy. the register must not be re-written until ckrdy goes high. note that this register is protected by a lock. to write to th is register the unlock register has to be written first. refer to section 10.7.7 ?pm unlock register? on page 123 for details. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------- 76543210 cpudiv - - - - cpusel
118 42023e?sam?07/2013 atsam4l8/l4/l2 10.7.3 pbx clock select name: pbxsel access type: read/write offset: 0x00c-0x018 reset value: 0x00000000 ? pbdiv, pbsel: pbx division and clock select pbdiv = 0: apbx clock equals main clock. pbdiv = 1: apbx clock equals main clock divided by 2 (pbsel+1) . note that if pbdiv is written to 0, pbsel should also be written to 0 to ensure correct operation. also note that writing this register clears sr.ckrdy. the register must not be re-written until sr.ckrdy goes high. note that this register is protected by a lock. to write to th is register the unlock register has to be written first. refer to section 10.7.7 ?pm unlock register? on page 123 for details. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------- 76543210 pbdiv - - - - pbsel
119 42023e?sam?07/2013 atsam4l8/l4/l2 10.7.4 clock mask name: cpumask/hsbmask/pbamask/pbbmask/pbcmask/pbdmask access type: read/write offset: 0x020-0x034 reset value: 0x00000001/0x000001e2/0x00000000/0x00000001/0x0000001f/0x0000003f- ? mask: clock mask if bit n is cleared, the clock for module n is stopped. if bit n is set, the clock for module n is enabled according to the cur rent power mode. the number of implemented bits in each mask register, as well as which module clock is controlled by each bit, is shown in table 10-5 . after reset, some modules are enabled by default (shown as gray cell). 31 30 29 28 27 26 25 24 mask[31:24] 23 22 21 20 19 18 17 16 mask[23:16] 15 14 13 12 11 10 9 8 mask[15:8] 76543210 mask[7:0] table 10-5. maskable module clocks in atsam4l. bit cpumask hsbmask pbama sk pbbmask pbcmask pbdmask 0 ocd pdca iisc flashcalw pm bpm 1- flashcalw spi hramc1 chipid bscif 2- hramc1 (picocache ram) tc0 hmatrix scif ast 3 - usbc tc1 pdca freqm wdt 4 - crccu twim0 crccu gpio eic 5- apba bridge twis0 usbc picouart 6- apbb bridge twim1 pevc - 7- apbc bridge twis1 - - 8- apbd bridge usart0 - - 9 - aesa usart1 - - 10 - - usart2 - - 11 - - usart3 - - 12 - - adcife - - -
120 42023e?sam?07/2013 atsam4l8/l4/l2 note that this register is protected by a lock. to write to th is register the unlock register has to be written first. refer to section 10.7.7 ?pm unlock register? on page 123 for details. 13--dacc--- 14--acifc--- 15--gloc--- 16--abdacb--- 17 - - trng - - - 18--parc--- 19--catb--- 20------ 21--twim2--- 22--twim3--- 23 - - lcdca - - - 24------ 25------ 31:26------ table 10-5. maskable module clocks in atsam4l. bit cpumask hsbmask pbama sk pbbmask pbcmask pbdmask
121 42023e?sam?07/2013 atsam4l8/l4/l2 10.7.5 divided clock mask name: pbadivmask access type: read/write offset: 0x040 reset value: 0x0000007f ? mask: clock mask if bit n is written to zero, the clock divided by 2 (n+1) is stopped. if bit n is written to one, the clock divided by 2 (n+1) is enabled according to the current power mode. table 10-6 shows what clocks are affect ed by the different mask bits. note that this register is protected by a lock. to write to th is register the unlock register has to be written first. refer to section 10.7.7 ?pm unlock register? on page 123 for details. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 - ------ 15 14 13 12 11 10 9 8 -------- 76543210 - mask[6:0] table 10-6. divided clock mask bit usart0 usart1 usart2 usart3 tc0 tc1 0----timer_clock2timer_clock2 1---- - - 2 clk_usart/ div clk_usart/ div clk_usart/ div clk_usart/ div timer_clock3 timer_clock3 3---- - - 4----timer_clock4timer_clock4 5---- - - 6----timer_clock5timer_clock5
122 42023e?sam?07/2013 atsam4l8/l4/l2 10.7.6 clock failure detector control register name: cfdctrl access type: read/write offset: 0x054 reset value: 0x00000000 ? sfv: store final value 0: the register is read/write. 1: the register is read-only, to protect against further accidental writes. ? cfden: clock failure detection enable 0: clock failure detector is disabled. 1: clock failure detector is enabled. note that this register is protected by a lock. to write to th is register the unlock register has to be written first. refer to section 10.7.7 ?pm unlock register? on page 123 for details. 31 30 29 28 27 26 25 24 sfv------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------- 76543210 -------cfden
123 42023e?sam?07/2013 atsam4l8/l4/l2 10.7.7 pm unlock register name: unlock access type: write-only offset: 0x058 reset value: 0x00000000 to unlock a write protected register, first write to the unlock register with the address of the register to unlock in the addr field and 0xaa in the key field. then, in the next ap b access write to the register specified in the addr field. ?key: unlock key write this bit field to 0xaa to enable unlock. ? addr: unlock address write the address of the register to unlock to this field. 31 30 29 28 27 26 25 24 key 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 ------ addr[9:8] 76543210 addr[7:0]
124 42023e?sam?07/2013 atsam4l8/l4/l2 10.7.8 interrupt enable register name: ier access type: write-only offset: 0x0c0 reset value: 0x00000000 writing a zero to a bit in this register has no effect. writing a one to a bit in this register will set the corresponding bit in imr. 31 30 29 28 27 26 25 24 ae------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------wake 76543210 - - ckrdy - - - - cfd
125 42023e?sam?07/2013 atsam4l8/l4/l2 10.7.9 interrupt disable register name: idr access type: write-only offset: 0x0c4 reset value: 0x00000000 writing a zero to a bit in this register has no effect. writing a one to a bit in this register will clear the corresponding bit in imr. 31 30 29 28 27 26 25 24 ae------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------wake 76543210 - - ckrdy - - - - cfd
126 42023e?sam?07/2013 atsam4l8/l4/l2 10.7.10 interrupt mask register name: imr access type: read-only offset: 0x0c8 reset value: 0x00000000 0: the corresponding interrupt is disabled. 1: the corresponding interrupt is enabled. this bit is cleared when the corresponding bit in idr is written to one. this bit is set when the corresponding bit in ier is written to one. 31 30 29 28 27 26 25 24 ae------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------wake 76543210 - - ckrdy - - - - cfd
127 42023e?sam?07/2013 atsam4l8/l4/l2 10.7.11 interrupt status register name: isr access type: read-only offset: 0x0cc reset value: 0x00000000 0: the corresponding interrupt is cleared. 1: the corresponding interrupt is pending. this bit is cleared when the corresponding bit in icr is written to one. this bit is set when the corresponding interrupt occurs. 31 30 29 28 27 26 25 24 ae------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------wake 76543210 - - ckrdy - - - - cfd
128 42023e?sam?07/2013 atsam4l8/l4/l2 10.7.12 interrupt clear register name: icr access type: write-only offset: 0x0d0 reset value: 0x00000000 writing a zero to a bit in this register has no effect. writing a one to a bit in this register will clear the corresponding bit in isr. 31 30 29 28 27 26 25 24 ae------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------wake 76543210 - - ckrdy - - - - cfd
129 42023e?sam?07/2013 atsam4l8/l4/l2 10.7.13 status register name: sr access type: read-only offset: 0x0d4 reset value: 0x00000000 ? ae: access error 0: no access error has occurred. 1: a write to lock protected register without unlocking it has occurred. ? wake: wake up 0: no wakeup has occurred. 1: a wakeup event has occurred. refer the wc ause register to know the wakeup source. ? ckrdy: clock ready 0: the cksel register has been written, and the new clock setting is not yet effective. 1: the synchronous clocks have frequencies as indicated in the cksel register. ? cfd: clock failure detected 0: main clock is running correctly. 1: failure on main clock detected. main clock reverting to rcsys. 31 30 29 28 27 26 25 24 ae------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------wake 76543210 - - ckrdy - - - - cfd
130 42023e?sam?07/2013 atsam4l8/l4/l2 10.7.14 peripheral power control register name : ppcr access type: read/write offset: 0x160 reset value: 0x000001fe ? fwbod18: flash wait bod18 0: at powerup, flash waits for the bod18 to be ready and calibrated to go back to normal mode. 1: at power up, flash does not wait for the bod18 to be ready. ? fwbgref: flash wait bgref 0: when waking up, flash controller waits for the main bandgap to be ready to go back to normal mode. 1: when waking up, flash controller does not wait for the main bandgap to be ready. 31 30 29 28 27 26 25 24 ppc[31:24] 23 22 21 20 19 18 17 16 ppc[23:16] 15 14 13 12 11 10 9 8 ppc[15:8] 76543210 ppc[7:0] table 10-7. peripheral power control bit name 0rstpun 1 catbrcmask 2 acifcrcmask 3 astrcmask 4 twis0rcmask 5 twis1rcmask 6 pevcrcmask 7 adcifercmask 8 vregrcmask 9fwbgref 10 fwbod18 31:11 -
131 42023e?sam?07/2013 atsam4l8/l4/l2 ? vregrcmask: vreg request clock mask 0: vreg request clock is disabled 1: vreg request clock is enabled ? adcifercmask: adcife request clock mask 0: adcife request clock is disabled 1: adcife request clock is enabled ? pevcrcmask: pevc request clock mask 0: pevc request clock is disabled 1: pevc request clock is enabled ? twis1rcmask: twis1 request clock mask 0: twis1 request clock is disabled 1: twis1 request clock is enabled ? twis0rcmask: twis0 request clock mask 0: twis0 request clock is disabled 1: twis0 request clock is enabled ? astrcmask: ast request clock mask 0: ast request clock is disabled 1: ast request clock is enabled ? acifcrcmask: acifc request clock mask 0: acifc request clock is disabled 1: acifc request clock is enabled ? catbrcmask: cat request clock mask 0: cat request clock is disabled 1: cat request clock is enabled ? rstpun: reset pullup 0: pullup on the external reset pin is disabled. 1: pullup on the external reset pin is enabled. note that this register is protected by a lock. to write to th is register the unlock register has to be written first. refer to section 10.7.7 ?pm unlock register? on page 123 for details.
132 42023e?sam?07/2013 atsam4l8/l4/l2 10.7.15 reset cause name: rcause access type: read-only offset: 0x180 reset value: latest reset source ? bod33: brown-out 3.3v reset this bit is set when the last reset was due to the supply voltage being lower than the bod 3.3v (bod33) threshold level. ? por33: power-on reset this bit is set when the last reset was due to th e i/o voltage being lower than the por33 threshold. ? ocdrst: ocd reset this bit is set when the last reset was due to the sysresetreq bit in the aircr regist er of the cpu having been written to one. ? bkup: backup reset this bit is set when the last reset was due to a wake up from the backup mode. ? wdt: watchdog reset this bit is set when the last reset was due to a watchdog time-out. ? ext: external reset pin this bit is set when the last reset wa s due to the reset_n pin being pulled low. ? bod: brown-out reset this bit is set when the last reset was due to the core supply voltage being lower than the brown-out threshold level. ? por: power-on reset this bit is set when the last reset was due to the core supply voltage being lower than the power-on threshold level, 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 - - bod33 - - por33 - ocdrst 76543210 - bkup - - wdt ext bod por
133 42023e?sam?07/2013 atsam4l8/l4/l2 10.7.16 wake cause register name: wcause access type: read-only offset: 0x184 reset value: latest wake source a bit in this register is set on wake up caused by the peripheral referred to in table 10-8 on page 133 . 31 30 29 28 27 26 25 24 wcause[31:24] 23 22 21 20 19 18 17 16 wcause[23:16] 15 14 13 12 11 10 9 8 wcause[15:8] 76543210 wcause[7:0] table 10-8. wake cause bit wake cause 0twi slave 0 1twi slave 1 2 usbc 3 psok 4 bod18 irq 5 bod33 irq 6picouart 7 lcdca 15:8 - 16 eic 17 ast 31:18 -
134 42023e?sam?07/2013 atsam4l8/l4/l2 10.7.17 asynchronous wake up enable register name :awen access type: read/write offset: 0x188 reset value: 0x00000000 each bit in this register corresponds to an asynchronous wake up, according to table 10-9 on page 134 . 0: the corresponding wake up is disabled. 1: the corresponding wake up is enabled 31 30 29 28 27 26 25 24 awen[31:24] 23 22 21 20 19 18 17 16 awen[23:16] 15 14 13 12 11 10 9 8 awen[15:8] 76543210 awen[7:0] table 10-9. asynchronous wake up bit asynchronous wake up 0twi slave 0 1twi slave 1 2 usbc 3 psok 4 bod18 irq 5 bod33 irq 6picouart 7 lcdca 31:6 -
135 42023e?sam?07/2013 atsam4l8/l4/l2 10.7.18 fast sleep register name : fastsleep access type: read/write offset: 0x194 reset value: 0x00000000 each bit in this register corresp onds to a clock source set as the main clock just before entering power save mode and just aft er wake-up to make the wakeup time faster. 0: the corresponding clock source is not set as the main clock after wake-up. 1: the corresponding clock source is set as the main clock after wake-up. ? osc: oscillator ?pll: pll ? fastrcosc: 00001: rc80 00010: rcfast 00100: rc1m 01000: reserved 10000: reserved ? dfll: dfll 31 30 29 28 27 26 25 24 -------dfll 23 22 21 20 19 18 17 16 - - - fastrcosc 15 14 13 12 11 10 9 8 -------pll 76543210 -------osc
136 42023e?sam?07/2013 atsam4l8/l4/l2 10.7.19 configuration register name: config access type: read-only offset: 0x3f8 reset value: - this register shows the configuration of the pm. ? hsbpevc: hsb pevc clock implemented 0: hsbpevc not implemented. 1: hsbpevc implemented. ? pbd: apbd implemented 0: apbd not implemented. 1: apbd implemented. ? pbc: apbc implemented 0: apbc not implemented. 1: apbc implemented. ? pbb: apbb implemented 0: apbb not implemented. 1: apbb implemented. ? pba: apba implemented 0: apba not implemented. 1: apba implemented. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------- 76543210 hsbpevc - - - pbd pbc pbb pba
137 42023e?sam?07/2013 atsam4l8/l4/l2 10.7.20 version register name: version access type: read-only offset: 0x3fc reset value: - ? variant: variant number reserved. no functionality associated. ? version: version number version number of the module. no functionality associated. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 ---- variant 15 14 13 12 11 10 9 8 - - - - version[11:8] 76543210 version[7:0]
138 42023e?sam?07/2013 atsam4l8/l4/l2 10.8 module configuration the specific configuration for ea ch pm instance is listed in t he following tables. the module bus clocks listed here are connected to the system bus clocks. refer to the ?synchronous clocks?, ?peripheral clock masking? sections for details. table 10-10. power manager clocks clock name description clk_pm clock for the pm bus interface table 10-11. register reset values register reset value version 0x00000441 table 10-12. effect of the different reset events por reset bod33 reset bod18 reset external reset wdt reset ocd reset backup reset ast 32 khz xosc oscillator 32 khz rc oscillator ynn nnn n rc oscillators calibration register y n n n n n y watchdog registers y y y y n y n bod33 control register y n y y y y n bod18 control register y y n y y y n backup domain except ast, wdt and 32 khz oscillators yyy yyy n core domain excluding ocd y y y y y y y ocd system a nd ocd registers y y y y n n y
139 42023e?sam?07/2013 atsam4l8/l4/l2 11. backup power manager (bpm) rev: 1.2.0.5 11.1 features ? supports the power scaling technique ? controls the power save modes ? manages i/o lines pin muxing for backup mode ? manages i/o lines retention in backup mode ? stores the wake up source from backup mode 11.2 overview the backup power manager (bpm) located in the backup domain is an extension of the power manager (pm) module. to optimize power consumption, the bpm supports the power scaling technique. the bpm allows changing the power scaling configuration in bo th run and power save mode. the bpm allows the user to choose between different power save modes depending on appli- cation requirements. it controls the way the microcontroller enters or exits a power save mode. in backup mode, some i/o lines are dedicated to system wakeup. the bpm takes control of these i/o line pins muxing n eeded to wake up the system. the configuration of the i/o lines is kept in all power save modes. exiting the backup mode will reset the core domain and by default will put the i/o lines in their reset state. the bpm allows retaining the i/o line state when exiting the backup mode, preventing i/o lines from tog- gling during wake up. the bpm flags the wake up source when the backup mode is exited.
140 42023e?sam?07/2013 atsam4l8/l4/l2 11.3 block diagram figure 11-1. bpm block diagram 11.4 product dependencies in order to use this module, other parts of the system must be configured correctly, as described below. 11.4.1 clocks the clock for the bpm bus interface (clk_bpm) is generated by the power manager. this clock is enabled at reset, and can be disabled in the power manager. bpm vregif pb bus pmcon configuration bpm state machine cortex-m4 bpm interrupt user interface gpio controller eic i/o line management power scaling power save modes wake up management backup reset backup eic pins clk_bpm nvic pm voltage regulator eic bod33 bod18 wdt ast wfi instruction rcause bkupmux backup domain bkupwcause standard eic pins
141 42023e?sam?07/2013 atsam4l8/l4/l2 11.4.2 interrupts the bpm interrupt line is connected to the nvic. using the bpm interrupt requires the nvic to be programmed first. 11.4.3 debug operation if a backup mode is requested by the system while in debug mode, the core domain is kept to those in run mode, and the debug modules are k ept running to allow the debugger to access internal registers. when exiting the backup mode upon a wakeup even t, all the core domain is reset but the debug session. it allows the user to keep using its current debug session. note: hot plugging in backup mode is not supported. 11.5 functional description 11.5.1 power scaling the power scaling feature is programmed thanks to the pmcon register where the user can select the power scaling configuration (ps) and the power scaling change request (pscreq). when exiting the backup mode, the power scaling configuration field (pmcon.ps) is unchanged. it ensures that the system is running in the same power scaling configuration. when a reset occurs ( see ?reset description? on page 112. ), the pmcon.ps field is reset to its default value, and then, the system goes back to the reset power configuration mode (run0 mode). refer to the low power technique chapter ( see ?power scaling? on page 56. ) to understand the sequence to apply. 11.5.2 power save modes the power save mode feature is supported thanks to the pmcon register where the user can select the sleep mode configuration (sl eep), the backup mode (bkup) and the reten- tion mode (ret). the sleepdeep bit located in the system control register in the cortex m4 should also be used to manage the different power save modes. the selected power save mode is entered after a wfi instruction. refer to the low power technique chapter ( see ?power scaling? on page 56. ) to have more details. 11.5.3 i/o lines pin muxing in backup mode in all modes including the backup mode, a subset of pins (external interrupts) can be directly routed to a list of peripheral function bypassing the gpio controller.
142 42023e?sam?07/2013 atsam4l8/l4/l2 figure 11-2. i/o lines pin muxing diagram to enable the backup pin muxing, the user should set a one to the corresponding bit of the backup pin muxing register (bkuppmux) in the bpm. the backup alternate function overrides the gpio function. to allow the system to be waken up by an external interrupt pin in backup mode, the backup pin muxing should be enabled. 11.5.4 i/o lines retention in backup mode when the device exits the backup mode by a wake up source, the i/o line configuration can be released or stretched, based on the ret bit in the ioret register of the bpm: ? if the bpm.ioret.ret bit is set to 0: the i/o lin es are released and then driven by the reset value of the gpio controller module. ? if the bpm.ioret.ret bit is set to 1: the backup configuration of i/o lines are kept until the user sets the ret bit to 0. it allows the i/o lines to be retained until the user has programmed the gpio controller to its correct value, preventing i/o lines from toggling during wake up. 11.5.5 wakeup from backup mode any enabled asynchronous sour ces, located in the backup do main, can wake the system up. the user should first enable the wakeup sour ce by programming the backup wake up enable register (bkupwen). the wakeup source is stored inside the back up wake up cause register. the user can read it once the backup mode is exited and the run mode is back. see ?backup mode? on page 54. in the low power technique chapter to have more details. note: if eic is used to wakeup the system, the backup pin muxing bit must be set ( see ?i/o lines pin muxing in backup mode? on page 141. ) user interface gpio controller external interrupt controller backup eic pins bkupmux backup domain m u x eic pins
143 42023e?sam?07/2013 atsam4l8/l4/l2 11.5.6 precautions when en tering power save mode. modules communicating with external circuits should be disabled before entering a power save mode that will stop the module oper ation. this prevents erratic beha vior when entering or exiting power save mode. refer to the relevant module documentation for recommended actions. communication between the synchronous clock domains is disturbed when entering and exiting power save modes. this means that bus transactions are not allowed between clock domains affected by the power save mode. the system may hang if the bus clocks are stopped in the middle of a bus transaction. when entering a power save mode where ahb clocks are stopped, all ahb masters must be stopped before entering the power save mode. also, if there is a chance that any apb write operations are incomplete, the cpu should perform a read operation from any register on the apb bus before executing the wfi in struction. this will stall the cpu while waiting for any pend- ing apb operations to complete. note: all these recommendations al so apply when c hanging the power scaling as the system is halted. 11.5.7 interrupts the bpm has a number of interrupts: ? ae: access error, set if a lock protected register is written without first being unlocked. ? psok: power scaling configuration ok, set if the requested power configuration is ready (regulator mode ready, regulator output voltage as expected).
144 42023e?sam?07/2013 atsam4l8/l4/l2 11.6 user interface note: 1. the reset value for this register is device specific. refe r to the module configuration sect ion at the end of this chapt er. table 11-1. bpm register memory map offset register register name access reset 0x0000 interrupt enable register ier write-only 0x00000000 0x0004 interrupt disable register idr write-only 0x00000000 0x0008 interrupt mask register imr read-only 0x00000000 0x000c interrupt status register isr read-only 0x00000000 0x0010 interrupt clear register icr write-only 0x00000000 0x0014 status register sr read-only 0x00000000 0x0018 unlock register unlock read/write 0x00000000 0x001c power mode control register pmcon read/write 0x00000000 0x0028 backup wake up cause register bkupwcause read-only 0x00000000 0x002c backup wake up enable register bkupwen read/write 0x00000000 0x0030 backup pin muxing register bkuppmux read/write 0x00000000 0x0034 input output retention register ioret read/write 0x00000000 0x00fc version register version read-only - (1)
145 42023e?sam?07/2013 atsam4l8/l4/l2 11.6.1 interrupt enable register name: ier access type: write-only offset: 0x0000 reset value: 0x00000000 writing a zero to a bit in this register has no effect. writing a one to a bit in this register will set the corresponding bit in imr. 31 30 29 28 27 26 25 24 ae------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------- 76543210 ------ psok
146 42023e?sam?07/2013 atsam4l8/l4/l2 11.6.2 interrupt disable register name: idr access type: write-only offset: 0x0004 reset value: 0x00000000 writing a zero to a bit in this register has no effect. writing a one to a bit in this register will clear the corresponding bit in imr. 31 30 29 28 27 26 25 24 ae------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------- 76543210 ------ psok
147 42023e?sam?07/2013 atsam4l8/l4/l2 11.6.3 interrupt mask register name: imr access type: read-only offset: 0x0008 reset value: 0x00000000 0: the corresponding interrupt is disabled. 1: the corresponding interrupt is enabled. this bit is cleared when the corresponding bit in idr is written to one. this bit is set when the corresponding bit in ier is written to one. 31 30 29 28 27 26 25 24 ae------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------- 76543210 ------ psok
148 42023e?sam?07/2013 atsam4l8/l4/l2 11.6.4 interrupt status register name: isr access type: read-only offset: 0x000c reset value: 0x00000000 0: the corresponding interrupt is cleared. 1: the corresponding interrupt is pending. this bit is cleared when the corresponding bit in icr is written to one. this bit is set when the corresponding interrupt occurs. 31 30 29 28 27 26 25 24 ae------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------- 76543210 ------ psok
149 42023e?sam?07/2013 atsam4l8/l4/l2 11.6.5 interrupt clear register name: icr access type: write-only offset: 0x0010 reset value: 0x00000000 writing a zero to a bit in this register has no effect. writing a one to a bit in this register will clear the corresponding bit in isr. 31 30 29 28 27 26 25 24 ae------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------- 76543210 ------ psok
150 42023e?sam?07/2013 atsam4l8/l4/l2 11.6.6 status register name: sr access type: read-only offset: 0x0014 reset value: 0x00000000 ? ae: access error 0: no access error has occured. 1: a write to lock protected regist er without unlocking it has occured. ? psok: power scaling ok 0: the power scaling configuration is not yet ready. 1: the current power scaling configuration is ready. the regulato r mode is ready, the regulator output voltage has reached the expected value, the flash is ready. 31 30 29 28 27 26 25 24 ae------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------- 76543210 ------ psok
151 42023e?sam?07/2013 atsam4l8/l4/l2 11.6.7 unlock register name: unlock access type: write-only offset: 0x018 reset value: 0x00000000 to unlock a write protected register, first write to the unlock register with the address of the register to unlock in the addr field and 0xaa in the key field. then, in the next pb access write to the register specified in the addr field. ?key: unlock key write this bit field to 0xaa to enable unlock. ? addr: unlock address write the address of the register to unlock to this field. 31 30 29 28 27 26 25 24 key 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 ------ addr[9:8] 76543210 addr[7:0]
152 42023e?sam?07/2013 atsam4l8/l4/l2 11.6.8 power mode control register name :pmcon access type: read/write offset: 0x001c reset value: 0x00000000 ? fastwkup: fast wakeup 0: normal wakeup time for analog modules. 1: fast wakeup time for analog modules. to have an optimal fast wakeup, this is also required to conf igure the pm.fastsleep register to wakeup the system on a fast rc oscillator clock sour ce. if the flash high speed mode is enabled, the fast wakeup ha s no effect. during the wakeup period, the flashcalw module is forced to operate in wait state 1 until the bpm.sr.psok bit is one. ? ck32s: 32khz-1khz clock source selection 0: the 32khz and 1khz clock sources are from the osc32k. 1: the 32khz and 1khz clock sources are from the rc32k. ? sleep: sleep mode configuration ? ret: retention mode 0: the power save mode will not be the retention mode. 31 30 29 28 27 26 25 24 -------fastwkup 23 22 21 20 19 18 17 16 --- - ---ck32s 15 14 13 12 11 10 9 8 - sleep - - ret bkup 76543210 ---- pscreq ps table 11-2. sleep mode configuration sleep description 0 the cpu clock is stopped. 1 the cpu and ahb clocks are stopped. 2 the cpu, ahb, pb and gclk clocks are stopped. clock s ources (osc, fast rc oscilla tors, pll, dfll) are still running. 3 the cpu, ahb, pb, gclk clocks and clock sources (osc, rcfast, pll, dfll) are stopped. rcsys is still running. rc32k or osc32k are still running if enabled.
153 42023e?sam?07/2013 atsam4l8/l4/l2 1: the power save mode will be the rete ntion mode if the scr.sleepdeep bit is set to 1 and the backup mode is set to zero. ? bkup: backup mode 0: the power save mode will not be the backup mode. 1: the power save mode will be the backup mode if the scr.sleepdeep bit is set to 1. ? pscreq: power scaling change request 0: a new power scaling is not requested. 1: a new power scaling is requested. this bit is cleared by hardware after the completion of the power scaling change. ? ps: power scaling configuration value refer to section 6.1.5 ?power save mode summary table? on page 56 and to figure 6-1 on page 51 this field is reset to its default value when exiting the backup mode. note that this register is protected by a lock. to write to th is register the unlock register has to be written first. refer to section 11.6.7 ?unlock register? on page 151 for details.
154 42023e?sam?07/2013 atsam4l8/l4/l2 11.6.9 backup wake up cause register name: bkupwcause access type: read-only offset: 0x0028 reset value: latest wake up source from backup mode a bit in this register is set when the system is waking up from the back up mode and the wake up s ource is caused by the peripheral referred to in table 11-3 on page 154 . 31 30 29 28 27 26 25 24 bkupwc[31:24] 23 22 21 20 19 18 17 16 bkupwc[23:16] 15 14 13 12 11 10 9 8 bkupwc[15:8] 76543210 bkupwc[7:0] table 11-3. backup wake up cause bit wake cause 0eic 1 ast 2 wdt interrupt 3 bod33 interrupt 4 bod18 interrupt 5 picouart interrupt 31:6 -
155 42023e?sam?07/2013 atsam4l8/l4/l2 11.6.10 backup wake up enable register name : bkupwen access type: read/write offset: 0x002c reset value: 0x00000000 each bit in this register corresponds to a wa ke up cause from the backup mode, according to table 11-3 on page 154 . 0: the corresponding wake up source is disabled. 1: the corresponding wake up source is enabled. 31 30 29 28 27 26 25 24 bkupwen[31:24] 23 22 21 20 19 18 17 16 bkupwen[23:16] 15 14 13 12 11 10 9 8 bkupwen[15:8] 76543210 bkupwen[7:0] table 11-4. asynchronous wake up bit asynchronous wake up 0eicen 1 asten 2wdten 3 bod33en 4 bod18en 5picouarten 31:6 -
156 42023e?sam?07/2013 atsam4l8/l4/l2 11.6.11 backup pin muxing register name: bkuppmux access type: read/write offset: 0x0030 reset value: 0x00000000 ? bkuppmux: backup pin muxing map a peripheral function required in backup mode to a dedicated pad. each bit in this register corresponds to an alte rnate function associated to a pin, according to table 11-5 on page 156 . 0: the corresponding backup pin is not selected. 1: the corresponding backup pin is selected. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 ------- bkuppmux[8] 76543210 bkuppmux[7:0] table 11-5. backup pin muxing bit backup pin name alternate function 0 pb01 eic[0] 1 pa06 eic[1] 2 pa04 eic[2] 3 pa05 eic[3] 4 pa07 eic[4] 5 pc03 eic[5] 6 pc04 eic[6] 7 pc05 eic[7] 8 pc06 eic[8] 31-9 - -
157 42023e?sam?07/2013 atsam4l8/l4/l2 11.6.12 input output retention register name: ioret access type: read/write offset: 0x0034 reset value: 0x00000000 ? ret: retention on i/o lines afte r waking up from the backup mode 0: i/o lines are not held after wa king up from the backup mode. 1: i/o lines are held after waking up from the backup mode, until ret is written to 0. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------- 76543210 -------ret
158 42023e?sam?07/2013 atsam4l8/l4/l2 11.6.13 version register name: version access type: read-only offset: 0x00fc reset value: - ? variant: variant number reserved. no functionality associated. ? version: version number version number of the module. no functionality associated. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 ---- variant 15 14 13 12 11 10 9 8 - - - - version[11:8] 76543210 version[7:0]
159 42023e?sam?07/2013 atsam4l8/l4/l2 11.7 module configuration the specific configuration for each bpm instance is listed in the following tables. the module bus clocks listed here are connected to the system bus clocks. refer to the ?synchronous clocks?, ?peripheral clock masking? and ?power save modes? sections for details. table 11-6. power manager clocks clock name description clk_bpm clock for the bpm bus interface table 11-7. register reset values register reset value version 0x00000120
160 42023e?sam?07/2013 atsam4l8/l4/l2 12. backup system cont rol interface (bscif) rev: 1.0.0.0 12.1 features ? supports 32khz ultra-low-power oscillator (osc32k) ? supports 32khz rc oscillator (rc32k) ? supports 1mhz rc oscillator (rc1m) ? controls brown-out detectors (bod18 and bod33) ? controls the voltage regulation system ? four 32-bit general-purpose backup registers 12.2 overview the backup system control interface (bscif) controls the oscillators, bods, voltage regula- tion system and backup registers. it is located in backup domain.
161 42023e?sam?07/2013 atsam4l8/l4/l2 12.3 block diagram figure 12-1. bscif block diagram 12.4 i/o lines description asynchronous timer watchdog timer osc32k rc32k xin32 xout32 backup system control interface (bscif) apb bus bod33 bod18 voltage regulation system voltage regulator bandgap rc1m backup registers pmcon.ck32s (from bpm) nvic reset controller backup domain table 12-1. i/o lines description pin name pin description type xin32 crystal 32 input analog/digital xout32 crystal 32 output analog
162 42023e?sam?07/2013 atsam4l8/l4/l2 12.5 product dependencies in order to use this module, other parts of the system must be configured correctly, as described below. 12.5.1 power management the 32 khz oscillators (rc32k and osc32k) ar e not turned off in power save modes. bods are turned off in some power save modes and turned automatically on when the device wakes up. the voltage regulation system is controlled by the bpm, refer to section 11. ?backup power manager (bpm)? on page 139 for details. 12.5.2 clocks the bscif controls the 32khz oscillators as we ll as the 1mhz rc in the device. the oscillators can be used as source for the cpu and peripherals, selection of source is done in the power manager. the oscillator can also be used as sour ce for generic clocks. device modules using a 32 khz clock must choose between the 32 khz cr ystal oscillator and the rc 32 khz oscillator for the clock source. setting the ck32s bit to one in the pmcon register (pmcon.ck32s) will select the rc32k oscillator as the 32 khz clock s ource, and leaving it to zero will select the 32 khz crystal oscillator output. 12.5.3 interrupts the bscif interrupt request line is connected to the nvic. using the bscif interrupt requires the nvic to be programmed first. 12.5.4 debug operation the bscif does not interact with debug operations. 12.6 functional description 12.6.1 32khz oscillator (osc32k) operation rev: 2.0.0.0 the 32khz oscillator operates as the standard main oscillator. the 32khz oscillator can be used as source clock for the asynchronous timer (ast), the watchdog timer (wdt) and the brown out detectors (bods) when they are used in sampling mode. the 32khz oscillator can also be used as source for the generic clocks. the oscillator is disabled by default after reset. the oscillator is en abled by writing a one to the osc32 en able bit in the 32khz oscillator con- trol register (oscctrl32.osc32en). the oscillator is disabled by writing a zero to the osc32en bit, while keeping the other bits unchanged. writing to osc32en while also writing to other bits may result in unpredictable behavior. operation mode (external clock or crystal) is selected by writing to the os cillator mode bit in oscctrl32 (oscctrl32.mode). the oscilla- tor is an ultra low power design and remains enabled in all power save modes. the start-up time of the 32khz oscillator is selected by writing to the oscillator start-up time field in the oscctrl32 register (oscctrl 32.startup). the bscif masks the oscillator output during the start-up time, to ensure that no unstable clock cycles propagate to the digital logic. the osc32 ready bit in the power and clock status register (pclksr.osc32rdy) is set when the oscillator is stable and ready to be used as clock so urce. an interrupt can be gener-
163 42023e?sam?07/2013 atsam4l8/l4/l2 ated on a zero-to-one transition on pclksr.osc 32rdy if the osc32rdy bit in the interrupt mask register (imr.osc32rdy) is set. this bit is set by writing a one to the corresponding bit in the interrupt enable register (ier.osc32rdy). as a crystal oscillator usually requires a very long start-up time (up to 1 second), the 32khz oscillator will keep running across re sets, except a power-on reset (por). the current driven into the crystal can be adjusted according to the component specification requirements via the selcurr bitfield in the osc32ctrl register (osc32ctrl.selcurr). the 32khz oscillator also has a 1khz output (clk_1k). this is enabled by writing a one to the enable 1khz output bit in the oscctrl32 regi ster (oscctrl32.en1k). if the 32khz output clock is not needed when the clk_1k is enabled, this can be disabled by writing a zero to the enable 32khz output bit in the os cctrl32 register (oscctrl32.en32k). oscctrl32.en32k is set after a por. the clk_1k output is only usable when xin32 is con- nected to a crystal, and not when an external digital clock is applied on xin32. 12.6.2 32 khz rc oscillator (rc32k) rev: 1.0.0.1 the rc32k oscillator provides a tunable, lo w speed, low-power clock source. the rc32k is enabled by default as a system clock, except in static mode. the rc32k is enabled as a 32 khz generic clock source by writing a one to the enable bit in the rc32k control register (rc32kcr.en). it is disabled by writing a ze ro to rc32kcr.en. the rc32k is also available for direct use as a 32 khz clock, enabled by writing a one to the enable 32khz bit (rc32kcr.en32k). a 1 khz clock output can be enabled by writing a one to the enable 1khz bit (rc32kcr.en1k). the rc32k oscillator supports temperature compensation, which can be enabled for a more stable frequency. the temperature compensation is enabled by writing a one to the tempera- ture compensation enable bit (rc32kcr.tcen), and disabled by writing a zero. the frequency of the rc32k osc illator is controlled by two val ues in the rc32k tuning register rc32ktune.coarse and rc32ktune.fine. coarse is loaded by the fuses, and compen- sates for process variation, while fine is us ed to keep the frequency accurate over the temperature range. the coarse value can be overridden by the user by writing to the coarse field. the fine value can be tuned in two different modes, selected by the rc32kcr.mode bit where a zero is open loop mode and a one is closed loop mode. in open loop mode the user can tune the frequency by writing to the rc32ktune register. when writing to rc32ktune, the user must wa it for the pclksr.rc32krdy bit to go high before the val ue has been committed to the oscillator. see section 42.7 ?oscillator characteris- tics? on page 1142 for how fine and coarse affects the frequency. in closed loop mode the rc32k automatically tunes fine to synchronize the rc32k oscillator with an external 32768 hz reference. the referenc e source is selected by the reference select bit (rc32kcr.ref). in closed loop mode, the rc32 k does a binary search on the fine field to converge towards the reference. when the rc32k has converged on the reference frequency, the rc32k lock bit (pclksr.rc32klock) is se t, and the rc32k continues to measure and track the reference frequency. if the user switches from closed loop mode to open loop mode and back to closed loop again, rc32k will restart the synchronization procedure, disregarding previous locks.
164 42023e?sam?07/2013 atsam4l8/l4/l2 if the reference clock stops when the rc32k is in closed loop mode, the rc32k reference error bit (pclksr.rc32krefe) is set, and the rc32k stays in closed loop mode, keeping the current fine value. when the reference clock starts again, the rc32k automatically resumes the tracking of the reference clock. in closed loop mode, if the correct frequency is out of range for the fine value, it will saturate due to an incorrect coarse setting. the rc3 2k saturation bit (pclksr.rc32ksat) is set and the user can read the current fine value to determine further action. note that rc32ktune can only be written to when closed loop mode is disabled. when disabling closed loop mode, wait for the rc32k ready bit (pcl ksr.rc32krdy) to be set before writing to rc32ktune, and then wait for it to be set aga in before going back to closed loop mode. the fine field will always read as ze roes when in cl osed loop mode. if the range of fine is not sufficient to obtain the correct frequency, rc32ktune can be modi- fied by the user with a new coarse value to change the fine offset. the user should select a fine value of 0x20 before enabling closed loop mode. when the rc32k is enabled with either en, en32k, or en1k in the rc32kcr register, the oscillator is kept running du ring all power save modes. 12.6.3 brow-out detector (bod) operation rev: 1.1.0.0 the brown-out detectors bod18 and bod 33 monitors the vddcore and vddio supplies respectively, and compares the voltage with t he brown-out trigger level, as set in the bod18/33level register. the bod is disabled by default, but can be enabled either by soft- ware or by flash fuses. the brown-out detector can generate either an interrupt or a reset when the supply voltage is below the brown-out trigger level, as shown in figure 12-2 . the bod18/33 detection status can be read from the power and clock status register (pclksr.bod18/33det).
165 42023e?sam?07/2013 atsam4l8/l4/l2 figure 12-2. bod18/33 block diagram the bod18/33 is enabled by writing a one to the enable bit in the bod18/33 control register (bod18/33ctrl.en). when enabl ed, the bod18/33 output will be masked during half a sys- tem rc oscillator (rcsys) clock cycle and an additional two cpu cl ock cycles, in order to avoid false results. see section 42.9 ?analog characteristics? on page 1150 for parametric details. 12.6.3.1 monitored voltages ? vddio (bod33) ? vddcore (bod18) 12.6.3.2 supported modes the bod18/33 can operate in two different modes: ? continuous mode ? sampling mode the operation mode bit in the control regist er (bod18/33ctrl.mode) is used to select the mode of operation. power manager (pm) interrupt bod33 vddcore vddana reset bod33 detected cont mode oneshot mode bod33 hyst bod33 level bod33 reset nvic bod18 bod18 detected cont mode oneshot mode bod18 hyst bod18 level bod18 reset scif bscif
166 42023e?sam?07/2013 atsam4l8/l4/l2 12.6.3.3 continuous mode when bod18/33ctrl.mode is zero, the bod18/33 operates in continuous mode. in continu- ous mode the bod18/33 is enabled and continously monitoring the supply voltage. the continuos mode is the default mode. 12.6.3.4 sampling mode the sampling mode, also called the one-shot mode, is a low power mode where the bod18/33 is being repeatedly enabled by incoming positive edges from a configurable choice of sampling clock sources including the system rc oscillator , the 32 khz crystal oscillator (osc32k) and the rc 32khz oscillator (r c32k). in sampling mode, the bod18/33 will monitor the vddio/vddcore voltages for a very short amount of time before it turns itself off again. sam- pling mode is enabled by writing a one to bod18/33ctrl.mode. the frequency of the bod18/33 one-shot pulses can be varied by the prescaler select field in the bod18/33sampling register (bod18/33sampling.psel). f sampling = f clk_presc / 2 (psel+1) since the sampling mode clock is different fr om the pb clock domain, synchronization among the clocks is necessary. figure 12-3 shows a block diagram of the sampling mode. the bod18/33 synchronization ready bit in pc lksr (pclksr.bod18/33synrdy) shows the ready status of the synchronizer. writing attempts to the bod18/33sampling register are ignored while pclksr.bod18/33synrdy is zero. figure 12-3. sampling mode block diagram 12.6.3.5 clock sources the clock mux is used to select the clock source for the samp ling mode. the clock source is enabled/disabled by the clock enable bit in the bod18/33sampling register (bod18/33sampling.cen). the clock source select bit (bod18/33sampling.cssel) is used to select the clock so urce for the sampling mode. there are two possible clock sources for the sampling prescaler: prescaler synchronizer pb interface unsync bus fsampling osc32k or rc32k rcsys cssel sync bus clk_pb clk_presc cen psel mode
167 42023e?sam?07/2013 atsam4l8/l4/l2 ? rcsys: this oscillator is always enabled w hen selected as clock source. refer to section 10. ?power manager (pm)? on page 108 for details about rc sys and the power save modes. refer to the section 42.7 ?oscillator characteristics? on page 1142 chapter for the oscillator?s frequency characteristics. ? osc32k or rc32k: this oscilla tor has to be enabled in the bscif interface before using it as clock source for the bod18/33. the bod18/33 will not be able to detect if this clock is stopped. it is recommended to disable the bod18/33 before disabling the clock, to avoid freezing the bod18/33 in an undefined state. 12.6.3.6 changing clock source the bod18/33sampling.cen bit should always be disabled before changing the sampling clock source. to change the clock for the bo d18/33 the following steps need to be taken: 1. write a zero to the cen bit, leaving the other bits unchanged, to stop the clock. 2. wait until cen reads as zero, giving the clock time to stop. 3. select a new clock source by writing to the bod18/33sampling.cssel bit. 4. write a one to the cen bit, leaving the other bits unchanged, to enable the clock. 5. wait until cen reads as one, giving the clock time to start. 12.6.3.7 changing the prescaler to change the prescaler value for the bod18/33 during sampling mode the following steps need to be taken: 1.wait until the pclksr.bod18/33synrdy bit is one. 2.write the selected va lue to the psel field. 12.6.3.8 bod18/33 interrupts/reset the bod18/33 can generate either an interrupt or a reset based on the action field in the bod18/33ctrl register. the interrupt/reset is triggered when there is a voltage (vddio/vddcore) failure. before enabling the bod18/33 reset mode the action field must first be initialized to zero in order to avoid any false bod18/33 detection when the bod18/33 is not ready. 12.6.3.9 hysteresis the hysteresis functionality may be used in both continuous and sampling mode. writing a one to the hyst bit in bod18/33ctrl can add hysteresis to the bod18/33 trigger level. 12.6.3.10 bod18 threshold ranges the bod18 has two threshold voltage ranges. there is a standard threshold range, for opera- tion in power scaling 0 and 2 mode (ps0 andps2), and a low threshold range for operation at lower supply voltage values, such as power scaling 1 mode or deep power save mode. the user must take care of using the right threshold settings according to the different modes. refer to section 42.9 ?analog characteristics? on page 1150 for regulator minimal values in the differ- ent modes
168 42023e?sam?07/2013 atsam4l8/l4/l2 12.6.3.11 power save modes in continuous mode the bod1 8/33 will be off during wait , retention and backup power save modes. in sampling mode the bod18/33 is enabled in all power save modes. 12.6.3.12 flash fuses it is not recommended to override the default factory settings, but can be done (after reset) by writing to the bod18/33 registers. refer to the fuse settings chapter for more details about bod18/33 fuses and how to program these fuses. if the flash calibration done (fcd) bit in the bod1 8/33ctrl register is 0 at reset, the flash cal- ibration will be redone and the bod18/33ctrl.fcd bit will be set before program execution starts in the cpu. if bod18/ 33ctrl.fcd is one, the bod18/33 configuration will not be altered after reset. 12.6.4 voltage regulator (vreg) the embedded voltage regulator can be used to supply all the digital logic in the core and the backup power domains. the vreg features three different modes: normal mode, low power mode (lp) and ultra low power mode (ulp). to support power scaling and power save mode features, the vreg is controlled by the backup power manager (bpm). after a reset, the vreg is enabled. if an external voltage is applied on the vddcore pin, the vreg can be disabled by writing a one to the disable bit of the vreg configuration register (vregcr.dis). when the regulator has reached its expected value, the vregok bit in the pclksr register is set. an interrupt is generated on a zero-to-one transition of vregok. 12.6.4.1 register protection to prevent unexpected writes due to software bu gs, write access to the vregcr register is pro- tected by a locking mechanism, for details refer to section 12.7.7 ?unlock register? on page 179 . to prevent further modifications by software, the contents of the calibration (vreg.calib) and disable (vregcr.dis) fields can be set as read-only by writing a one to the store final value bit (vregcr.sfv). once this bit is set, the contents of vregcr can not be modified until a por18 reset is applied. table 12-2. bod18/33 in different modes mode continuous mode possible actions during different modes sampling mode possible actions during different modes run reset interrupt reset interrupt sleep reset interrupt reset interrupt wait off off reset delayed interrupt retention off off reset delayed interrupt backup off off reset delayed interrupt
169 42023e?sam?07/2013 atsam4l8/l4/l2 12.6.4.2 1mhz rc oscillator the 1mhz rc oscillator which is used for swit ching regulator operation can also be internally routed to be used as a logic clock. this osci llator is controlled by the rc1mcr register. its startup calibration value is read from flash fuses. 12.6.5 bandgap rev: 1.1.0.7 the bandgap provides a stable voltage reference us ed by the internally by the device. this ref- erence is automatically turned on at startup. to save power consumption, the bandgap features a low power bandgap voltage reference which may be automatically enabled in wait or ret mode. all modules using the bandgap voltage reference, get their signal through a bandgap buffer. these buffers are controlled automatically. 12.6.6 backup registers (br) rev: 1.0.0.1 four 32-bit backup registers are available to st ore values when the device is in backup power save mode. these registers will keep their content even when the vddcore supply and the internal regulator supply voltage supplies are removed. the backup registers can be accessed by reading from and writing to the br0, br1, br2, and br3 registers. 12.6.7 interrupts the scif has the following interrupt sources: ? ae - access error: ? a protected scif register was accessed without first being correctly unlocked. ? lpbgrdy- access error: ? a 0 to 1 transition on the pclksr.lpbgrdy bit is detected.. ? vregok: voltage regulator ok: ? set on 0 to 1 transition on the pclksr.vregok bit is detected. ? sswrdy: buck voltage regulator has stopped switching: ? set on 0 to 1 transition on the pclksr.sswrdy bit is detected. ? bod18synrdy - bod18 synchronization ready: ? set on 0 to 1 transition on the pclksr.bod18synrdy bit is detected. ? bod33synrdy - bod33 synchronization ready: ? set on 0 to 1 transition on the pclksr.bod33synrdy bit is detected. ? bod18det - brown out 1.8 detected: ? set on 0 to 1 transition on the pclksr.bod18det bit is detected.
170 42023e?sam?07/2013 atsam4l8/l4/l2 ? bod33det - brown out 3.3 detected: ? set on 0 to 1 transition on the pclksr.bod33det bit is detected. ? rc32ksat- rc32k fine value saturated: ? 0: the rc32k autocalibration has not saturated the fine value. ? 1: the rc32k autocalibration has brought fine into saturation. ? rc32krefe - rc32k reference error: ? 0: the rc32k has detected a running reference frequency. ? 1: the rc32k reference frequency has stopped. ? rc32klock - rc32k locked to reference: ? 0: the rc32k has not obtained a lock to the reference frequency. ? 1: the rc32k has obtained alock to the reference frequency. ? rc32krdy - rc32k ready: ? 0: reads from fine and coarse will yiel d invalid values. writes to fine and coarse is not yet complete ? 1: fine and coarse can be read, writes to fine and coarse have been commited. ? osc32rdy - 32khz oscillator ready: ? a 0 to 1 transition on the pclksr.osc32rdy bit is detected. the interrupt sources will generate an interrupt request if the corr esponding bit in the interrupt mask register is set. the interrupt sources are ored together to form one interrupt request. the bscif will generate an in terrupt requ est if at least one of the bits in the in terrupt mask register (imr) is set. bits in imr are set by writing a one to the corresponding bit in the interrupt enable register (ier), and cleared by writing a one to the corresponding bit in the interrupt disable register (idr). the interrupt request remains active until the corresponding bit in the interrupt status register (isr) is cleared by writing a one to the corresponding bit in the interrupt clear register (icr). because all the interrupt sour ces are ored together, the interrupt request from the bscif will remain active until all the bits in isr are cleared.
171 42023e?sam?07/2013 atsam4l8/l4/l2 12.7 user interface note: 1. the reset value is device specific. refer to the m odule configuration section at the end of this chapter. 2. the reset value of this register depends on factory calibration. table 12-3. bscif register memory map offset register register name access reset 0x0000 interrupt enable register ier write-only 0x00000000 0x0004 interrupt disable register idr write-only 0x00000000 0x0008 interrupt mask register imr read-only 0x00000000 0x000c interrupt status register isr read-only 0x00000000 0x0010 interrupt clear register icr write-only 0x00000000 0x0014 power and clocks status register pclksr read-only 0x00000000 0x0018 unlock register unlock write-only 0x00000000 0x001c chip specific configuration register cscr read/write 0x00000000 0x0020 oscillator 32 control register oscctrl32 read/write 0x00000004 0x0024 32khz rc oscillator control register rc32kcr read/write 0x00000000 0x0028 32khz rc oscillator tuning register rc32ktune read/write 0x00000000 0x002c bod33 control register bod33ctrl read/write - (2) 0x0030 bod33 level regist er bod33level read/write - (2) 0x0034 bod33 sampling control regist er bod33sampling read/write 0x00000000 0x0038 bod18 control regi ster bod18ctrl read/write - (2) 0x003c bod18 level register bod18level read/write - (2) 0x0040 bod18 sampling control regist er bod18sampling read/write 0x00000000 0x0044 voltage regulator configuration register vregcr read/write - (1) 0x0058 1mhz rc clock configuration register rc1mcr read/write 0x00000f00 0x0060 bandgap control register bgctrl read/write 0x00000000 0x0064 bandgap status register bgsr read-only - (2) 0x0078 - 0x0084 backup register n br read/write 0x00000000 0x03e4 backup register interface version register brifbversion read-only - (1) 0x03e8 bgrefif version register bgrefifbversion read-only - (1) 0x03ec voltage regulator version register vregifgversion read-only - (1) 0x03f0 bod version regist er bodifcversion read-only - (1) 0x03f4 32khz rc oscillator versi on register rc32kifbversion read-only - (1) 0x03f8 32 khz oscillator version register osc32ifaversion read-only - (1) 0x03fc bscif version register version read-only - (1)
172 42023e?sam?07/2013 atsam4l8/l4/l2 12.7.1 interrupt enable register name: ier access type: write-only offset: 0x0000 reset value: 0x00000000 writing a zero to a bit in this register has no effect. writing a one to a bit in this register will set the corresponding bit in imr. 31 30 29 28 27 26 25 24 ae------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 - - - lpbgrdy - vregok sswrdy bod18syn rdy 76543210 bod33syn rdy bod18det bod33det rc32sat rc32krefe rc32klock rc32krdy osc32rdy
173 42023e?sam?07/2013 atsam4l8/l4/l2 12.7.2 interrupt disable register name: idr access type: write-only offset: 0x0004 reset value: 0x00000000 writing a zero to a bit in this register has no effect. writing a one to a bit in this register will clear the corresponding bit in imr. 31 30 29 28 27 26 25 24 ae------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 - - - lpbgrdy - vregok sswrdy bod18syn rdy 76543210 bod33syn rdy bod18det bod33det rc32sat rc32krefe rc32klock rc32krdy osc32rdy
174 42023e?sam?07/2013 atsam4l8/l4/l2 12.7.3 interrupt mask register name: imr access type: read-only offset: 0x0008 reset value: 0x00000000 0: the corresponding interrupt is disabled. 1: the corresponding interrupt is enabled. a bit in this register is cleared when the corresponding bit in idr is written to one. a bit in this register is set when the corresponding bit in ier is written to one. 31 30 29 28 27 26 25 24 ae------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 - - - lpbgrdy - vregok sswrdy bod18syn rdy 76543210 bod33syn rdy bod18det bod33det rc32sat rc32krefe rc32klock rc32krdy osc32rdy
175 42023e?sam?07/2013 atsam4l8/l4/l2 12.7.4 interrupt status register name: isr access type: read-only offset: 0x000c reset value: 0x00000000 0: the corresponding interrupt is cleared. 1: the corresponding interrupt is pending. a bit in this register is cleared when the corresponding bit in icr is written to one. a bit in this register is set when the corresponding interrupt occurs. 31 30 29 28 27 26 25 24 ae------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 - - - lpbgrdy - vregok sswrdy bod18syn rdy 76543210 bod33syn rdy bod18det bod33det rc32sat rc32krefe rc32klock rc32krdy osc32rdy
176 42023e?sam?07/2013 atsam4l8/l4/l2 12.7.5 interrupt clear register name: icr access type: write-only offset: 0x0010 reset value: 0x00000000 writing a zero to a bit in this register has no effect. writing a one to a bit in this register will clear the corresponding bit in isr. 31 30 29 28 27 26 25 24 ae------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 - - - lpbgrdy - vregok sswrdy bod18syn rdy 76543210 bod33syn rdy bod18det bod33det rc32sat rc32krefe rc32klock rc32krdy osc32rdy
177 42023e?sam?07/2013 atsam4l8/l4/l2 12.7.6 power and clocks status register name: pclksr access type: read-only offset: 0x0014 reset value: 0x00000000 ?lpbgrdy: 0: low power bandgap not enabled or not ready. 1: low power bandgap is stable and ready to be used as voltage reference source. ? rc1mrdy: 0: rc1m oscillator not enabled or not ready. 1: rc1m oscillator is stable and ready to be used as clock source. ? sswrdy: buck voltage regul ator has stopped switching: 0: buck voltage regulator has not requested to stop switch ing or the stop switching request is not yet acknowledged. 1: buck voltage regulator has stopped s witching after a stop switching request. this bit should be read only when the switching regulator feature is used. ? bod18synrdy: 1: no bod18 synchronization is ongoing. 0: a bod18 synchronization is ongoing. ? bod33synrdy: 1: no bod33 synchronization is ongoing. 0: a bod33 synchronization is ongoing. ? bod18det: 0: no bod18 event. 1: bod18 has detected that power supply is going below bod18 reference value. ? bod33det: 0: no bod33 event. 1: bod33 has detected that power supply is going below bod33 reference value. ? rc32ksat: 0: the rc32k autocalibration has not saturated the fine value. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 - - - lpbgrdy rc1mrdy vregok sswrdy bod18syn rdy 76543210 bod33syn rdy bod18det bod33det rc32sat rc32krefe rc32klock rc32krdy osc32rdy
178 42023e?sam?07/2013 atsam4l8/l4/l2 1: the rc32k autocalibration has brought fine into saturation. ? rc32krefe: 0: the rc32k has detected a running reference frequency. 1: the rc32k reference frequency has stopped. ? rc32klock: 0: the rc32k has not obtained a lock to the reference frequency. 1: the rc32k has obtained alock to the reference frequency. ? rc32krdy: 0: reads from fine and coarse will yield invalid values. writes to fine and coarse is not yet complete 1: fine and coarse can be read, writes to fine and coarse have been comitted. ? osc32rdy: 0: osc32k not enabled or not ready. 1: osc32k is stable and ready to be used as clock source.
179 42023e?sam?07/2013 atsam4l8/l4/l2 12.7.7 unlock register name: unlock access type: write-only offset: 0x0018 reset value: 0x00000000 to unlock a write protected register, first write to the unlock r egister with the address of the re gister to unlock in the addr field and 0xaa in the key field. then, in the next pb ac cess write to the register specified in the addr field. ? key: unlock key write this bit field to 0xaa to enable unlock. ? addr: unlock address write the address offset of the register to unlock to this field. 31 30 29 28 27 26 25 24 key 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 ------ addr[9:8] 76543210 addr[7:0]
180 42023e?sam?07/2013 atsam4l8/l4/l2 12.7.8 32khz oscillator control register name: oscctrl32 access type: read/write reset value: 0x00000004 note: this register is only reset by power-on reset ? reserved this bit must always be written to zero. ? startup: oscillator start-up time select start-up time for 32 khz oscillator ? selcurr: current selection 31 30 29 28 27 26 25 24 reserved ------- 23 22 21 20 19 18 17 16 ----- startup[2:0] 15 14 13 12 11 10 9 8 selcurr[3:0] - mode[2:0] 76543210 ----en1ken32k-osc32en table 12-4. start-up time fo r 32 khz oscillator startup number of rcsys clock cycle approximative equivalent time (rcosc = 115 khz) 00 0 1128 1.1ms 2 8192 72.3 ms 3 16384 143 ms 4 65536 570 ms 5 131072 1.1 s 6 262144 2.3 s 7 524288 4.6 s
181 42023e?sam?07/2013 atsam4l8/l4/l2 select current driven into the crystal. ? mode: oscillator mode ? en1k: 1 khz output enable 0: the 1 khz output is disabled. 1: the 1 khz output is enabled. ? en32k: 32 khz output enable 0: the 32 khz output is disabled. 1: the 32 khz output is enabled. ? osc32en: 32 khz oscillator enable 0: the 32 khz oscillator is disabled table 12-5. crystal current selection selcurr current value (na) 050 175 2100 3125 4150 5175 6200 7225 8250 9275 10 300 (recommended value) 11 325 12 350 13 375 14 400 15 425 table 12-6. operation mode for 32 khz oscillator mode description 0 external clock connected to xin32 1 crystal mode. crystal is connected to xin32/xout32. 2reserved 3 crystal mode with amplitude controlled mo de. crystal is connected to xin32/xout32. 4 crystal and high current mode. cryst al is connected to xin32/xout32. 5 crystal with high current mode and amplitude cont rolled mode. crystal is connected to xin32/xout32. 6reserved 7reserved
182 42023e?sam?07/2013 atsam4l8/l4/l2 1: the 32 khz oscillator is enabled
183 42023e?sam?07/2013 atsam4l8/l4/l2 12.7.9 32 khz rc oscillator control register name: rc32kcr access type: read/write reset value: 0x00000000 ? fcd: flash calibration done signifies that coarse in the rc32kcalib regi ster has been loaded with value from fuses. 0: fuses not loaded. calib will be loaded on reset. 1: fuses loaded. calib will keep its current value on reset. ? ref: reference select selects the reference clock for the closed loop mode. 0: the osc32k is selected as the reference. 1: generic clock is selected for reference. see modu le configuration for the generic clock configuration. ? mode: mode selection 0: rc32k operates in open loop mode. 1: rc32k operates in closed loop mode. ? en1k: enable 1 khz output 0: 1 khz output is disabled. 1: 1 khz output is enabled. ? en32k: enable 32 khz output 0: 32 khz output is disabled. 1: 32 khz output is enabled. ? tcen: temperature compensation enable 0: the oscillator is not temperature compensated. 1: the oscillator is temperature compensated. ? en: enable as generic clock source 0: the oscillator is not enabled as a generic clock source. 1: the oscillator is enabled as a generic clock source. note that this register is protected by a lock. to write to th is register the unlock register has to be written first. refer to section 12.7.7 ?unlock register? on page 179 for details. 31 30 29 28 27 26 25 24 ------ - - 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -- --- --- 76543210 fcd - ref mode en1k en32k tcen en
184 42023e?sam?07/2013 atsam4l8/l4/l2 12.7.10 rc32k tuning register name: rc32ktune access type: read/write reset value: 0x002c0020 ? coarse: coarse value the offset value for fine. ? fine: fine value the fine calibration value. if in closed loop mode, this field is not accessible where reads return undefined values and writes are discarded. note that this register is protected by a lock. to write to th is register the unlock register has to be written first. refer to section 12.7.7 ?unlock register? on page 179 for details. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 - coarse[4:0] 15 14 13 12 11 10 9 8 -------- 76543210 - - fine[5:0]
185 42023e?sam?07/2013 atsam4l8/l4/l2 12.7.11 bod control register name: bod18/33ctrl access type: read/write reset value: - ? sfv: bod control register store final value 0: bod control register is not locked. 1: bod control register is locked. once locked, the control register can not be re-written, only a reset unlocks the sfv bit. ? fcd: bod fuse calibration done this bit is set to one after any reset. 0:flash calibration to be redone after a bod reset. 1:flash calibration not to be redone after a bod reset. ? mode: operation modes 0: continuous mode. 1: sampling mode. ? action: action ? hyst: bod hysteresis 0: no hysteresis. 1: hysteresis enabled. 31 30 29 28 27 26 25 24 sfvfcd------ 23 22 21 20 19 18 17 16 -------mode 15 14 13 12 11 10 9 8 ------ action 76543210 ------hysten table 12-7. action action[1:0] description 00 no action. 01 the bod generates a reset. 10 the bod generates an interrupt. 11 no action.
186 42023e?sam?07/2013 atsam4l8/l4/l2 ? en: enable 0: the bod is disabled. 1: the bod is enabled.
187 42023e?sam?07/2013 atsam4l8/l4/l2 12.7.12 bod sampling control register name: bod18/33sampling access type: read/write reset value: - ? psel: prescaler select select the prescaler divide-by output for the bod sampling mode. ? cssel: clock source select 0: selects the rcsys as bod sampling clock source. 1: selects the 32khz clock as bod sampling clock source . setting the ck32s bit to one in the pmcon register (pmcon.ck32s) will select the rc32k oscillator as the 32 khz clock source, and leaving it to zero will select the 32 khz crystal oscillator output. ? cen: clock enable writing a zero to this bit will stop the bod sampling clock. writing a one to this bit will start the bod sampling clock. 0: the bod sampling clock is either disabl ed and stopped, or enabled but not yet stable. 1: the bod sampling clock is either enabled and stable, or disabled but not yet stopped. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 - - - - psel[3:0] 76543210 - - - - - - cssel cen
188 42023e?sam?07/2013 atsam4l8/l4/l2 12.7.13 bod level register name: bod18/33level access type: read/write reset value: 0x00000000 ? range: bod threshold range (available for bod18 only) 0: the standard threshold range is selected. see section 42.9 ?analog characteristics? on page 1150 for actual voltage levels. 1: the low threshold range is selected. see section 42.9 ?analog characteristics? on page 1150 for actual voltage levels. note that any change to the range field of the bod18level regi ster should be done with the bod18 deactivated, this is to avoid spurious resets or interrupts. ? val: bod value this field sets the triggering voltage threshold for the bod. see section 42.9 ?analog characteristics? on page 1150 for actual voltage levels. note that any change to the val field of the bod18/33level regi ster should be done with the bod deactivated, this is to avoid spurious resets or interrupts. 31 30 29 28 27 26 25 24 range------ 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------- 76543210 - - val[5:0]
189 42023e?sam?07/2013 atsam4l8/l4/l2 12.7.14 voltage regulator configuration register name: vregcr access type: read/write reset value: - ? sfv: store final value 0: the dis field is read/write. 1: the dis field is read-only, to pr otect against further accidental writes. ? sswevt: stop switching on event enable 0: the stop switching mechanism is not controlled by the peripheral event controller. 1: the stop switching mechanism is contro lled by the peripheral event controller. this bit should be set only when the switching regulator feature is used. ? ssw: stop switching 0: the switching regulator is not forced to stop switching. 1: the switching regulator is forced to stop switching if the sswevt bit is set to zero. this bit should be set only when the switching regulator feature is used. ? ssg: spread spectru m generator enable 0: the spread spectrum of the internal switching oscillator is disabled. 1: the spread spectrum of the intern al switching oscillator is enabled. to operate, the spread spectrum functionality requir es the clkoen in the rc1mcr register to be enabled. this bit should be set only when the switching regulator feature is used. ? dis: voltage regulator disable 0: the voltage regulator is enabled. 1: the voltage regulator is disabled. note that this register is protected by a lock. to write to th is register the unlock register has to be written first. refer to section 12.7.7 ?unlock register? on page 179 for details. 31 30 29 28 27 26 25 24 sfv------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 - - - - - sswevt ssw ssg 76543210 -------dis
190 42023e?sam?07/2013 atsam4l8/l4/l2 12.7.15 1mhz rc clock configuration register name: rc1mcr access type: read/write reset value: - ? clkcal: 1mhz rc osc calibration calibration field of the internal rc oscillator. ? clkoen: 1mhz rc osc clock output enable 0: the 1mhz rc oscillator is not output. 1: the 1mhz rc oscillator is output, available as a logic clock. ? fcd: flash calibration done this bit is set to 1 when the clkcal field has been loaded by the flash fuses after a reset (read only). 0: the flash calibration will be redone after any reset. 1: the flash calibration will only be redone after a power-on reset (por18). note that this register is protected by a lock. to write to th is register the unlock register has to be written first. refer to section 12.7.7 ?unlock register? on page 179 for details. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 - - - clkcal[4:0] 76543210 fcd------clkoen
191 42023e?sam?07/2013 atsam4l8/l4/l2 12.7.16 bandgap control register name: bgctrl access type: read/write reset value: 0x00000000 ? adcisel: adc input selection 0: no connection. 1: reserved. 2: adc is connected to the voltage reference. 3: reserved. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------tsen 76543210 ------ adcisel
192 42023e?sam?07/2013 atsam4l8/l4/l2 12.7.17 bandgap status register name: bgsr access type: read only reset value: 0x00000000 ? vref: voltage reference used by the system 0: both the bandgap voltage reference and the low power bandgap voltage reference are currently used by the system. 1: the bandgap voltage reference is currently used by the system. 2: the low power bandgap voltage reference is currently used by the system. 3: neither the bandgap voltage refere nce nor the low power bandgap voltage reference are used by the system. ? lpbgrdy: low power bandgap voltage reference ready 0: the low power bandgap voltage reference is not ready, therefore all modules using it as a source will not be able to operate correctly. 1: the low power bandgap voltage reference is ready. ? bgrdy: bandgap voltage reference ready 0: the bandgap voltage reference is not read y, therefore all modules using it as a source will not be able to operate correctly . 1: the bandgap voltage reference is ready. ? bgbufrdy: bandgap buffer ready 0: the corresponding bandgap buffer is not ready, therefore all mo dules using it as a source will not be able to operate correc tly. 1: the corresponding bandgap buffer is ready. refer to the ?bandgap buffer mapping? table in the scif module configuration section for details. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 - - - - vref lpbgrdy bgrdy 15 14 13 12 11 10 9 8 -------- 76543210 bgbufrdy[7:0]
193 42023e?sam?07/2013 atsam4l8/l4/l2 12.7.18 backup register n name: brn access type: read/write reset value: 0x00000000 this is a set of general-purpose read/write registers. data stored in these registers is retained when the device is in backup power save mode. note that this registers are protected by a lock. to write to these registers the unlock register has to be written first. refer to section 12.7.7 ?unlock register? on page 179 for details. 31 30 29 28 27 26 25 24 data[31:24] 23 22 21 20 19 18 17 16 data[23:16] 15 14 13 12 11 10 9 8 data[15:8] 76543210 data[7:0]
194 42023e?sam?07/2013 atsam4l8/l4/l2 12.7.19 backup register interface version register name: brifbversion access type: read-only offset: 0x03e4 reset value: - ? variant: variant number reserved. no functionality associated. ? version: version number version number of the module. no functionality associated. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 ---- variant 15 14 13 12 11 10 9 8 - - - - version[11:8] 76543210 version[7:0]
195 42023e?sam?07/2013 atsam4l8/l4/l2 12.7.20 bandgap reference interface version register name: bgrefifbversion access type: read-only offset: 0x03e8 reset value: - ? variant: variant number reserved. no functionality associated. ? version: version number version number of the module. no functionality associated. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 ---- variant 15 14 13 12 11 10 9 8 - - - - version[11:8] 76543210 version[7:0]
196 42023e?sam?07/2013 atsam4l8/l4/l2 12.7.21 voltage regulator version register name: vregifgversion access type: read-only offset: 0x03ec reset value: - ? variant: variant number reserved. no functionality associated. ? version: version number version number of the module. no functionality associated. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 ---- variant 15 14 13 12 11 10 9 8 - - - - version[11:8] 76543210 version[7:0]
197 42023e?sam?07/2013 atsam4l8/l4/l2 12.7.22 brown-out detector version register name: bodifcversion access type: read-only offset: 0x03f0 reset value: - ? variant: variant number reserved. no functionality associated. ? version: version number version number of the module. no functionality associated. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 ---- variant 15 14 13 12 11 10 9 8 - - - - version[11:8] 76543210 version[7:0]
198 42023e?sam?07/2013 atsam4l8/l4/l2 12.7.23 32khz rc oscillator version register name: rc32kifbversion access type: read-only offset: 0x03f4 reset value: - ? variant: variant number reserved. no functionality associated. ? version: version number version number of the module. no functionality associated. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 ---- variant 15 14 13 12 11 10 9 8 - - - - version[11:8] 76543210 version[7:0]
199 42023e?sam?07/2013 atsam4l8/l4/l2 12.7.24 32khz oscillator version register name: osc32ifaversion access type: read-only offset: 0x03f8 reset value: - ? variant: variant number reserved. no functionality associated. ? version: version number version number of the module. no functionality associated. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 ---- variant 15 14 13 12 11 10 9 8 - - - - version[11:8] 76543210 version[7:0]
200 42023e?sam?07/2013 atsam4l8/l4/l2 12.7.25 bscif version register name: version access type: read-only offset: 0x03fc reset value: - ? variant: variant number reserved. no functionality associated. ? version: version number version number of the module. no functionality associated. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 ---- variant 15 14 13 12 11 10 9 8 - - - - version[11:0] 76543210 version[7:0]
201 42023e?sam?07/2013 atsam4l8/l4/l2 12.8 module configuration the specific configuration for each bscif instan ce is listed in the fo llowing tables.the module bus clocks listed here are connected to the system bus clocks. refer to section 10. ?power man- ager (pm)? on page 108 for details. table 12-8. module clock name module name clock name description bscif clk_bscif clock for t he bscif bus interface table 12-9. bandgap buffer mapping bit bg buffer description 0 flash flash 1pll pll 2 vreg main regulator 4adc adc 5lcd lcd table 12-10. register reset values register reset value brifbversion 0x00000100 bgrefifbversion 0x00000110 vregifgversion 0x00000110 bodifcversion 0x00000110 rc32kifbversion 0x00000100 osc32ifaversion 0x00000200 bscifversion 0x00000100
202 42023e?sam?07/2013 atsam4l8/l4/l2 13. system control interface (scif) rev: 1.3.0.0 13.1 features ? supports crystal oscill ator 0.6-30mhz (osc0) ? supports digital frequency locked loop 20-150mhz (dfll) ? supports phase locked loop 48-240mhz (pll) ? integrated low-powe r rc oscillator (rcsys) ? provides generic clocks (gclk) with wide frequency range ? controls 80mhz integrated rc oscillator (rc80m) ? controls 4/8/12mhz integrated rc oscillator (rcfast) 13.2 overview the system control interface (scif) controls the oscillators, generic clocks, pll and dfll. it is located in core domain. 13.3 block diagram figure 13-1. scif block diagram osc0 rcsys xin xout system control interface (scif) apb bus pll dfll nvic rcfast rc80m generic clock controller fractional prescaler high resolution prescaler to power manager system clocks vector to peripherals generic clocks vector
203 42023e?sam?07/2013 atsam4l8/l4/l2 13.4 i/o lines description 13.5 product dependencies in order to use this module, other parts of the system must be configured correctly, as described below. 13.5.1 i/o lines the scif provides a number of generic clock outputs, which can be connected to output pins, multiplexed with gpio lines. the user must first program the gpio controller to assign these pins to their peripheral function. if the i/o pins of the scif are not used by the application, they can be used for other purposes by the gpio controller. oscillator pins are also multiplexed with gpio. when oscillators are used, the related pins are controlled di rectly by the scif, overriding gpio settings. 13.5.2 power management oscillators are turned off in some power save modes and turned automatically on when the device wakes up. 13.5.3 clocks the scif controls some oscillato rs in the device. the oscillators can be used as source for the cpu and peripherals, sele ction of source is done in the power manager. the oscillator can also be used as source for generic clocks. 13.5.4 interrupts the scif interrupt request line is connected to the nvic. using the scif interrupt requires the nvic to be programmed first. 13.5.5 debug operation the scif does not interact with debug operations. 13.6 functional description 13.6.1 oscillator (osc) operation rev: 1.1.4.0 the main oscillator (oscn) is designed to be used with an external 0.6 to 30mhz crystal and two biasing capacitors, as shown in the electrical characteristics chapter, or with an external clock connected to t he xin. the oscillator can be used as source for the main clock in the device, as described in the powe r manager chapte r. the oscillator can be used as source for the generic clocks, as described in the generic clocks section. table 13-1. i/o lines description pin name pin description type xin crystal input analog/digital xout crystal output analog gclk3-gclk0 generic clock output output gclk_in1-gclk_in0 generic clock input input
204 42023e?sam?07/2013 atsam4l8/l4/l2 the oscillator is disabled by de fault after reset. wh en the oscillator is disabled, the xin and xout pins can be used as gener al purpose i/os. when the os cillator is enabl ed, the xin and xout pins are controlled directly by the scif , overriding gpio settings . when the oscillator is configured to use an external clock, the clock must be applied to the xin pin while the xout pin can be used as general purpose i/o. the oscillator is enabled by writin g a one to the oscillato r enable bit in the oscillator control reg- ister (oscctrln.oscen). operation mode (external clock or crystal) is selected by writing to the oscillator mode bit in oscctrln (oscctrln. mode). the oscillator is automatically dis- abled in certain sleep modes to reduce power consumption, as described in the power manager chapter. after a hard reset, or wh en waking up from a sleep mode w here the oscillators were disabled, the oscillator will need a certain amount of time to stabilize on the correct frequen cy. this start- up time can be set in the oscctrln register. the scif masks the oscilla tor outputs during the st art-up time, to ensure that no unstable clocks propagate to the digital logic. the oscn ready bit in the power and clock status register (pclksr.oscnrdy) is set when the oscillator is stable and ready to be used as clock source. an interrupt can be generated on a zero-to-one transition on oscnrdy if the oscnrdy bit in the interrupt mask register (imr.oscnrdy) is set. this bit is set by writing a one to the corresponding bit in the interrupt enable register (ier.oscnrdy). 13.6.2 pll operation rev: 1.1.2.0 the device contains one phase locked loop (pll), which is controlled by the phase locked loop interface (pllif). the pll is disabled by default, but can be enabled to provide high fre- quency source clocks for synchronous or gener ic clocks. the pll ca n use different clock sources as reference clock, refer to the ?pll clo ck sources? table in the scif module configu- ration section for details. the pll output is divided by a multiplication factor, and the pll compares the phase of the resulting clock to the reference clock. the pll will adjust its output frequency until the two compared clocks phases are equal, thus locking the output frequency to a multiple of the reference clock frequency. when the pll is switched on, or when changing the clock source or multiplication factor for the pll, the pll is unlocked and the output frequency is undefined. the pll clock for the digital logic is automatically masked when the pll is unlocked, to prevent the connected digital logic from receiving a too high frequency and thus become unstable. the pll can be configured by writing the pll control register (plln). to prevent unexpected writes due to software bugs, write access to th e plln register is protected by a locking mecha- nism, for details refer to section 13.7.7 ?unlock register? on page 228 .
205 42023e?sam?07/2013 atsam4l8/l4/l2 figure 13-2. pll with control logic and filters 13.6.2.1 enabling the pll before the pll is enabled it must be set up correctly. the pll oscillator select field ( pllosc) selects a source for the reference clock. the pll multiply factor (pllmul) and pll division factor (plldiv) fields must be written with the multiplication and division factors, respectively. the pllmul must always be greater than 1, creating the pll frequency: f vco = (pllmul+1)/plldiv ? f ref , if plldiv >0 f vco = 2?(pllmul+1) ? f ref , if plldiv = 0 the pll options (pllopt) field should be configured to proper values according to the pll operating frequency. the pllopt field can also be configured to divide the output frequency of the pll by 2 and wide-bandwidth mode, which allows faster startup time and out-of-lock time. it is not possible to change any of the pll configuration bits when the pll is enabled, any write to plln while the pll is enabled will be discarded. after setting up the pll, the pll is enabled by writing a one to the pll enable (pllen) bit in the plln register. 13.6.2.2 disabling the pll the pll is disabled by writing a zero to the p ll enable (pllen) bit in the plln register. after disabling the pll, the pll configuration fields becomes writable. 13.6.2.3 pll lock the lock signal for each pll is available as a plllockn flag in the pclksr register. if the lock for some reason is lost, the plllocklostn flag in pclksr register will be set. an interrupt can be generated on a 0 to 1 transition of these bits. phase detector output divider source clocks pllosc pllopt[0] pllmul lock bit mask pll clock input divider plldiv 1/2 pllopt[1] 0 1 vco f vco f pll lock counter f ref
206 42023e?sam?07/2013 atsam4l8/l4/l2 13.6.3 digital frequency locked loop (dfll) operation rev.: 1.1.0.0 the number of dflls is device specific. a specific dfll is referred to as dfllx, where x can be any number from 0 to n, where n refers to the last dfll instance. refer to the module config- uration section for details. the dfllx is controlled by the corresponding dfllx registers. dfllx is disabled by default, but can be enabled to provide a high-frequency source clock for synchro- nous and generic clocks. features: ? internal oscillator with no external components ? 20-150mhz output frequency ? can operate standalone as a high-frequency programmable oscillator in open loop mode ? can operate as an accurate frequency multiplier against a known frequency in closed loop mode ? optional spread-spectrum clock generation ? very high-frequency multiplication supported - can generate all frequencies from a 32khz reference clock dfllx can operate in both open loop mode and closed loop mode. in closed loop mode a low- frequency clock with high accuracy can be used as reference clock to get high accuracy on the output clock (clk_dfllx). to prevent unexpected writes due to software bugs , write access to the configuration registers is protected by a locking mechanism. for details refer to section 13.7.7 ?unlock register? on page 228 . figure 13-3. block diagram coarse fine 5 8 c l k _ d f l l x dfllx mul 16 clk_dfllx_ref frequency tuner dfllxlockc dfllxlockf dfllxtrackoob cstep fstep 5+8 calib range 2 4
207 42023e?sam?07/2013 atsam4l8/l4/l2 13.6.3.1 enabling the dfll dfllx is enabled by writing a one to the enable bit in the dfllx configuration register (dfllx- conf.en). no other bits or fields in dfllx conf must be changed simultaneously, or before dfllx is enabled. 13.6.3.2 internal synchronization due to multiple clock domains, values in the dfllx configuration registers need to be synchro- nized to other clock domains. the status of this synchronization can be read from the power and clocks status register (pclksr). before writing to any of the dfllx configuration registers, the user must check that the dfllx ready bit in pclksr is one (pclksr.dfllxrdy). when this bit is set, the dfllx can be configured, and clk_dfllx is ready to be used. any write to any of the dfllx configuration r egister while dfllxrdy is zero will be ignored. an interrupt can be generated on a zero-to-one transition of dfllxrdy. before reading the value in any of the dfllx configuration registers a one must be written to the synchronization bit in the dfllx synchroniz ation register (dfllxsync.sync). the dfllx configuration registers are ready to be read when pclksr.dfllxrdy is set. 13.6.3.3 disabling the dfll dfllx is disabled by writing a zero to dfllxconf.en. no other bits or fields in dfllxconf must be changed simultaneously. 13.6.3.4 open loop operation after enabling dfllx, open loop mode is selected. when operating in open loop mode the out- put frequency of t he dfllx will be determined by the values written to the calib ration value field and the range value field in dfllxconf (dfllxconf.calib and dfllxconf.range), and the coarse value field and the fine value field in the dfllx value register (dfllxval.coars and dfllxval.fine). calib is used for process calibration, and should not be changed by the user. it is loaded with a factory defined value stored in the flash fuses. the fuse calibration done bit in dfllxconf (dfllxconf.fcd) is set when the fuse values are loaded. writing a zero to this bit will reload the ca lib value from the flas h fuses after an y reset. refer to the fuse settings chapter for more details about how to program the fuses. range selects the frequency range of the dfllx, see table 13-2 . it is possible to change the value of dfllxconf.calib, dfllxconf.range, dfllx- val.coarse, and dfllxval.fine, and thereby the output frequency of the dfllx output clock, clk_dfllx, while the dfll is enabled and in use. clk_dfllx is ready to be used when pclksr.dfllxrdy is set after enabling the dfllx. the frequency range in open loop mode is 20-150mhz, but maximum frequency can be higher, and the minimum frequency can be lower. the best way to start the dfll at a specific frequency table 13-2. dfll frequency range range frequency range [mhz] 0 96-150 1 50-110 2 25-55 3 20-30
208 42023e?sam?07/2013 atsam4l8/l4/l2 in open loop mode is to first configure it for closed loop mode, see section 13.6.3.5 . when a lock is achieved, read back the coarse and fine values and switch to open loop mode using these values. an alternative approach is to use the frequency meter (freqm) to monitor the dfll frequency and adjust the coarse and fine values based on measurement results form the freqm. refer to the freqm chapter for more information on how to use it. note that the output frequency of the dfll will drift when in open loop mode du e to temperature and voltage changes. refer to section 42. ?electrical characteristics? on page 1120 for details. 13.6.3.5 closed loop operation dfllx must be correctly configured before closed loop operation can be enabled. after enabling dfllx, the dfllx must be configured in the following way: 1. enable and select a reference clock (clk_dfllx_ref). clk_dfllx_ref is a generic clock, refer to generic clocks section for details. 2. write an appropriate value to dfllxconf.range to choose desired range of the out- put frequency. 3. select the multiplication factor in the multiply factor fiel d in the dfllx multiplier regis- ter (dfllxmul.mul). care must be taken when choosing mul so the output frequency does not exceed the maximum frequency of the device. 4. select the maximum step size allowed in finding the coarse and fine values by writ- ing the appropriate values to the coarse maximum step field and fine maximum step field in the dfllx maximum step register (dfllxstep.cstep and dfllx- step.fstep). a small step size will ensure low overshoot on the output frequency, but can typically result in longer lock times. a high value might give a big overshoot, but can typically give faster lock ing. dfllxstep.cstep and df llxstep.fstep must not be higher than 50% of the maximum value of dfllxval.coarse and dfllxval.fine respectively. 5. optional: select start values for coarse and fine by writing the appropriate values to dfllxval.coarse and dfllxval.fine resp ectively. selecting values for coarse and fine that are close to the final values and small step sizes for cstep and fstep will reduce the time required to achieving lock on coarse and fine. if this step is skipped, coarse will start at its current va lue and fine will start at half its maximum value. 6. start the closed loop mode by writing a one to mode selection bit in dfllxconf (dfllxconf.mode). the frequency of clk_dfllx (f clk_dfllx ) is given by: where f clk_dfllx_ref is the frequency of the reference clock (clk_dfllx_ref). dfllx- val.coarse and dfllxval.fine are read-only in closed loop mode, and are controlled by the frequency tuner shown in figure 13-3 to meet user specified frequency. in closed loop mode, the value in dfllxval.coarse is used by the frequency tuner as a start- ing point for coarse and half th e maximum value of fine will be used as a starting point for fine. writing dfllxval.coarse to a value close to the final value before entering closed loop mode will reduce the time needed to get a lock on coarse. this can be done both before or after writing the multiplication value to dfllxmul.mul. if this is done after writing dfllx- mul.mul, the value written to dfllxval.fine will also be used as a starting point for fine instead of the default behavior which is to use half the maximum value of fine. f clk_dfllx dfllxmul.mul f clk_dfllx_ref ? =
209 42023e?sam?07/2013 atsam4l8/l4/l2 writing to dfllxmul.m ul while in closed loop mode will re set the locks. fine will be set to half its maximum value and the full locking sequence will be restarted. frequency locking the locking of the frequency in closed loop mode is divided into two stages. in the coarse stage the control logic quickly finds the co rrect value for dfllxval.coarse and thereby sets the output frequency to a value close to the correct frequency. the dfllx locked on coarse value bit in pclksr (pclksr.dfllxlockc) will be set when this is done. an interrupt can be generated on a zero-to-one transition of pclksr.dfllxlockc. in the fine stage the control logic tunes the value in dfllxval .fine so the output fr equency will be very cl ose to the desired frequency. dfllx locked on fine value bit in pclksr (pclksr.dfllxlockf) will be set when this is done. an interrupt can be generated on a zero-to-one transition of pclksr.dfllx- lockf. figure 13-4 shows the state diagram for the cl osed loop mode, and how the lock bits are set. figure 13-4. dfll closed loop state diagram clk_dfllx is ready to be used when pcl ksr.dfllxrdy is set after enabling dfllx. how- ever, the accuracy of the output frequency depends on which locks are set. for lock times, refer to section 42. ?electrical characteristics? on page 1120 chapter. frequency error measurement the ratio between clk_dfllx_ref and clk_dfllx is measured automatically. the differ- ence between this ratio and dfllxmul is stored in the multiplication ratio difference field in the dfllx ratio register (dfllxratio.ratiodiff). the relative error on clk_dfllx compared to the target frequency can be calculated as follows: drift compensation if the stable dfll frequency bit in dfllxconf (dfllxconf.stable) is zero, the frequency tuner will automatically compensate for drift in the f clk_dfllx without losing either of the locks. this will result in that dfll xval.fine can change after ever y measurement of clk_dfllx. measure dfllx frequency calculate new coarse value dfllxlockc 0 calculate new fine value dfllxlockf 0 1 1 stable 1 compen- sate for drift 0 error ratiodiff f clk_dfllx_ref ? f clk_dfllx -------------------------------------------------------------------------- - =
210 42023e?sam?07/2013 atsam4l8/l4/l2 if a one is written to dfllxc onf.stable, dfllxval.fine will ne ver change after fine lock is set. the frequency will be measured and th e error value can be read from the dfllxratio.ratiodiff. it is possible to change the value of dfllxconf.stable while in lock, without loosing the locks. this enables the user to let the dfllx co mpensate for drift if dfllxratio.ratiodiff is too big, and having a stable frequency when this is required. reference clock stop detection if clk_dfllx_ref stops or is running at a very slow frequency, the dfllx reference clock stopped bit in pclksr will be set (pclksr.dfllxrcs). note that the detection of a stopped reference clock will take a long time. the dfllx operate as if it was in open loop mode if it detects that the reference cl ock has stopped. close d loop mode operat ion will automatically resume if the clk_dfllx_ref is restarted. an interrupt can be generated on a zero-to-one transition on pclksr.dfllxrcs. 13.6.3.6 dealing with delay in the dfll the time from selecting a new clk_dfllx frequency until this frequency is output by the dfllx, can be up to several micro seconds. if the difference between the desired output fre- quency (clk_dfllx) and the frequency of clk_ dfllx_ref is small this can lead to an instability in the dfllx locking mechanism, which can prevent th e dfllx from achieving locks. to avoid this, a chill cycle where the clk_dfllx frequency is not measured can be enabled. the chill cycle is enabled by defa ult, but can be disabled by wr iting a one to the chill cycle dis- able bit in dfllxconf (dfllx conf.ccdis). enabling chill cycles might double the lock time. another solution to the same problem is to use le ss strict lock requirement s. this is called quick lock (ql), which is also enabled by default, but can be disabled by writing a one to the quick lock disable bit in dfllxconf (dfllxconf.qldis). the ql might lead to bigger spread in the outputted frequen cy than chill cycles, but the average output frequen cy is the same. if the target frequency is below 40mhz, one of these should always be enabled. 13.6.3.7 spread spectrum generator (ssg) when clk_dfllx is used as the main clock source for the device, the emi radiated from the device will be synchronous to f clk_dfllx . to provide better electrom agnetic compatibility (emc) dfllx can provide a clock with the energy spread in the frequency domain (spread spectrum). this is done by adding or subtracting values fr om the fine value. ssg is enabled by writing a one to the enable bit in the dfllx spread spectrum generator control register ( dfllx- ssg.en). the spread spectrum generator block diagram is shown in figure 13-5 . figure 13-5. spread spectrum generator block diagram. pseudorandom binary sequence spread spectrum generator fine 8 to dac clk_dfllx_ssg amplitude, stepsize
211 42023e?sam?07/2013 atsam4l8/l4/l2 the generic clock clk_dfllx_ssg must be configured and enabled before ssg is enabled, refer to generic clocks section for details. th is clock sets the rate at which the ssg changes the frequency of the dfll clock to generate a spread spectrum. the frequency of this clock should be higher than f clk_dfllx_ref to ensure that the dfllx can lock. optionally, the clock ticks can be qualified by a pseudo random binary sequence (prbs) if the prbs bit in dfllxssg is one (dfllxssg.prbs). this reduces the modulation effect of clk_dfllx_ssg frequency onto f clk_dfllx . the step size of the ssg is sele cted by writing to the ssg step size field in dfllxssg (dfllx- ssg.stepsize). if the step size is n, the output value from the ssg will be incremented/decremented by n on every tick of the source clock. dfllxssg.stepsize equal to zero or one will result in a step size equal to one. the amplitude of the frequency variation can be se lected by writing an appropriate value to the ssg amplitude field in dfllxssg (dfllx ssg.amplitude). if df llxssg.amplitude is larger than one, the sequenc e added to the fine value will dep end on both dfllxssg.ampli- tude and dfllxssg.stepsize, as shown in figure 13-6 . if dfllxssg.amplitude is zero the ssg will toggle on the lsb of the fine value. if dfllxssg.amplitude is one the ssg will add the sequence {1,-1, 0} to fine. figure 13-6. spread spectrum sequence added to fine value the spread spectrum generator is available in both open and closed loop mode. when spread spectrum is enabled in closed loop mode, and the dfllxssg.amplitude value is high, an overflow/underflow in fine is more likely to occur. 13.6.3.8 wake from power save modes dfllx may optionally reset its lock bits when waking from a power save mode which disables the dfllx. this is configured by the lose lock after wake bit in dfllxconf (dfllx- conf.llaw). if dfllxconf.llaw is zero t he dfll will be re-enabled and start running with the same configuration as before going to sleep even if the reference clock is not available. the locks will not be lost. when the refe rence clock has restar ted, the fine tracki ng will quickly com- pensate for any frequency drift during sleep if dfllxconf.stable is zero. if amplitude stepsize t
212 42023e?sam?07/2013 atsam4l8/l4/l2 dfllxconf.llaw is one when going to a power save mode where the dfllx is turned off, the dfllx will lose all its locks when waking up , and needs to regain th ese through the full lock sequence. 13.6.3.9 accuracy there are mainly three factors that decide the accuracy of the f clk_dfllx . these can be tuned to obtain maximum accuracy wh en fine lock is achieved. ? fine resolution: the frequency step between two fine values. this is relatively smaller for high output frequencies. ? resolution of the measurement: if the resolution of the measured f clk_dfllx is low, i.e. the ratio between the clk_dfllx frequency and the clk_dfllx_ref frequency is small, then the dfllx might lock at a frequency that is lower than the targeted frequency. it is recommended to use a reference clock frequency of 32khz or lower to avoid this issue for low target frequencies. ? the accuracy of the reference clock. 13.6.4 system rc oscillator (rcsys) rev: 1.1.4.0 the system rc oscillator has a startup time of th ree cycles, and is alwa ys available except in some sleep modes. refer to section 10. ?power manager (pm)? on page 108 for details. the system rc oscillator op erates at a nominal fr equency of 115khz, and is calibrated using the calibration value field (calib) in the rc oscilla tor calibration register (rccr). after a power- on reset (por), the rccr.calib field is loaded wi th a factory defined value stored in the flash fuses. refer to the fuse setting chapter for mo re details about rccr fu ses and how to program the fuses. if the flash calibration done (fcd) bit in the rccr is zero at any reset, the flash calibration will be redone and the rccr.fcd bit will be set before program executi on starts in the cpu. if the rccr.fcd is one, the flash calibration w ill only be redone afte r a power-on reset. to prevent unexpected writes to rccr due to software bugs, write access to this register is pro- tected by a locking mechanism. for details refer to section 13.7.7 ?unlock register? on page 228 . although it is not reco mmended to override default factory settings, it is still possible to override the default values by writing to rccr.calib. 13.6.5 4/8/12mhz rc oscillator (rcfast) operation rev: 2.0.02 the rcfast can be used as the main clock in the device, as described in section 10. ?power manager (pm)? on page 108 . the rcfast can also be used as source for the generic clocks, as described in the ?generic clocks? section of the scif. the rcfast is enabled by writin g a one to the oscillator enable bit in the rcfast configura- tion register (rcfastcfg.en), and disabled by writing a zero to this bit. when enabling the rcfast, rcfastcfg.en must be read back until it reads one. the user must ensure that the rcfast is fully disabled before enabling, and th at the rcfast is fully enabled before disabling by reading back rcfastcfg.en.
213 42023e?sam?07/2013 atsam4l8/l4/l2 after a power-on reset (por), the calibration field (rcfastcfg.calib) is loaded with a fac- tory-defined value stored in the flash fuses. the flash calibration done bit (rcfastcfg.fcd) is set when rcfastcfg.calib has been loaded from flash. for testing purposes, it is possible to override the default fuse values by writing to the rcfastcfg.calib field. to prevent unexpected frequency change, the rcfast must be dis- abled before modifying the calib field. to prevent unexpected writes due to software bugs, write access to the rcfastcfg register is protected by a locking mechanism. for details refer to section 13.7.7 ?unlock register? on page 228 . the rcfast is automatically switched off in certain sleep modes to reduce power con- sumption, as described in section 10. ?power manager (pm)? on page 108 . the rcfast is an internal oscilla tor that can, when operating in open loop mode, output a 4-, 8- or 12-mhz frequency, factory-calibrated under typical voltage and temperature. alternatively, the frequency can be further tuned to a multiplication ratio relative to the 32 khz reference clock. figure 13-7. rcfast block diagram 13.6.5.1 product dependencies the tuner uses a 32 khz clock as reference clock and should only be enabled when the 32 khz clock is running. refer to the 32 khz clock section for details. 13.6.5.2 general use the rcfast consists of two parts, one oscillato r and one tuner. the oscillator is enabled by writing a one to the oscillator en able bit (en) in the 4/8/12mhz rc oscillator configuration reg- ister (rcfastcfg). the tu ner is enabled by writing a one to the tuner enable bit (tuneen) in rcfastcfg. the oscillator has to be enabled for the tuner to work. 13.6.5.3 open loop mode if the tuner is disabled (rcfastcfg.tuneen is zero), the rcfast is in open loop mode. in open loop mode, the user can control the oscillation frequency by writing to the frequency range (frange) and calibration (calib) fields of the 4/8/12mhz rc oscillator configuration 4/8/12mhz trimmable rc oscillator counter count comparator 32khz clock input rcfast clock output trim value 0 1 calib tuneen frange nbperiods jitmode lockmargin lock locklost
214 42023e?sam?07/2013 atsam4l8/l4/l2 register (rcfastcfg). the frange and calib fields should only be updated when the rcfast is disabled. since this is in open loop mode, the frequency will be voltage, tempera- ture, and process dependent. refer to section 42. ?electrical characteristics? on page 1120 for details. 13.6.5.4 closed loop mode if the tuner is enabled (rcfastcfg.tuneen is one), the rcfast is in closed loop mode. in closed loop mode, the frequency is controlled by a tuner which measures the ratio between the rcfast output frequency and the 32 khz reference clock frequency. the initial output fre- quency is first chosen, when the rcfast is disabled, by writing to the frequency range (frange) and calibration (calib) fields of th e 4/8/12 mhz rc oscillato r configuration regis- ter (rcfastcfg). the rcfast clock periods are counted during one or several 32khz clock periods. and that count allows the tuner to adjust the rcfast trim value to get closer to the tar- get number of 32 khz clock per iods. the value of the rcfast cfg.nbperiods field is used to improve the tuner precision by counting rcfast clock periods across (1 << nbperiods) peri- ods of the 32 khz clock. th e nbperiods, lockmargin and ji tmode fields should only be updated when the tuner is disabled. the 32 khz reference clock is controlled by the bscif, refer to the 32 khz clock section for details. when a tuning procedure is completed, the lock bit (rcfastlock) in the status register (pclksr) will be set if the current count is within rcfastcfg.lockmargin of the target count. otherwise, the lock lost bit (rcfastlocklost) in pclksr will be set. 13.6.5.5 factory calibration if the flash calibration done (fcd) bit in rcfast cfg is zero at any rese t, then the calibration will be redone, using the factory calibratio n value stored in the flash fuses, and the rcfastcfg.fcd bit will be set before progra m execution starts in the cpu. if the rcfastcfg.fcd bit is one, then the rcfast configuration will not be changed during any reset except por reset. 13.6.5.6 register protection to prevent unexpected writes to rcfast registers due to software bugs, write access to the registers are protected by a locking mechanism. for details refer to section 13.7.7 ?unlock reg- ister? on page 228 . 13.6.6 80mhz rc oscillator (rc80m) operation rev: 1.0.0.1 the rc80m can be used as the main clock in the device, as described in section 10. ?power manager (pm)? on page 108 . the rc80m can also be used as source for the generic clocks, as described in the ?generic clocks? section of the scif. the rc80m is enabled by writing a one to the enable bit in the rc80m control register (rc80mcr.en), and disabled by writing a zero to this bit. when enabling the rc80m, rc80mcr.en must be read back until it reads one. the user must ensure that the rc80m is fully disabled before enabling, and that the rc 80m is fully enabled before disabling by reading back rc80mcr.en. after a power-on reset (por), the calibrati on value field (rc80mcr.c alib) is loaded with a factory defined value stored in the flash fuses.
215 42023e?sam?07/2013 atsam4l8/l4/l2 to prevent unexpected writes due to software bugs, write access to the rc80mcr register is protected by a locking mechanism. for details refer to section 13.7.7 ?unlock register? on page 228 . the rc80m is automatically switched off in certain sleep modes to reduce power consump- tion, as described in section 10. ?power manager (pm)? on page 108 . 13.6.7 generic clock prescalers rev: 1.0.2.0 the generic clocks can be sourced by two special prescalers to increase the generic clock fre- quency precision. these prescalers are named the high resolution prescaler (hrp) and the fractional prescaler (fp). 13.6.7.1 high reso lution prescaler the hrp is a 24-bit counter that can generate a very accurate clock waveform. the clock obtained has 50% duty cycle. figure 13-8. high resolution prescaler generation the hrp is enabled by writing a one to the high resolution prescaler enable (hrpen) bit in the high resolution prescaler co ntrol register (hrpcr). the user can select a clock source for the hrp by writing to the clock selection (cksel) field of the hrpcr register. the user must configure the high resolution prescaler clock (hrpclk) frequency by writing to the high resolution count (hrcount) field of th e high resolution counter (hrpcr) register. this results in the output frequency: f hrpclk = f src / (2*(hrcount+1)) the cksel field can not be changed dynamica lly but the hrcount field can be changed on- the-fly. 13.6.7.2 fractional prescaler the fp generates a clock whose average frequenc y is more precise than the hrp. however, this clock frequency is subject to jitter around th e target clock frequency. this jitter influence can be decreased by dividing this clock with the gclk divider. moreover the duty cycle of this clock is not precisely 50%. divider cksel hrpclk hrcount mask hrpen
216 42023e?sam?07/2013 atsam4l8/l4/l2 figure 13-9. fractional prescaler generation the fp is enabled by writing a one to the fpen bit in the fractional prescaler control register (fpcr). the user can select a clock source for the fp by writing to the cksel field of the fpcr register. the user must configure the fp frequency by writing to the fpmul and fpdiv fields of the fpmul and fpdiv registers. fpmul and fpdiv must not be equal to zero and fpdiv must be greater or equal to fpmul. this results in the output frequency: f fpclk = f src * fpmul/ (2*fpdiv) the cksel field can not be ch anged dynamically but the fpmul and fpdiv fields can be changed on-the-fly. ? jitter description as described in figure 13-10 , the clkfp half period lengths are integer multiples of the source clock period but are not always equals. however the difference between the low level half period length and the high level half period length is at the most one source clock period. this induces when fpdiv is not an integer mult iple of fpmul a jitter on the fpclk. the more the fpclk frequency is low, the more the jitter incidence is reduced. figure 13-10. fractional prescaler jitter examples 13.6.8 generic clocks rev: 1.1.2.0 divider cksel fpclk fpdiv mask fpen fpmul src clock fpclk fmul= 5 fdiv=5 fmul=3 fdiv=10 fmul=7 fdiv=9
217 42023e?sam?07/2013 atsam4l8/l4/l2 timers, communication modules, and other modules connected to external circuitry may require specific clock frequencies to op erate correctly. the scif define s a number of generic clocks that can provide a wide range of accurate clock frequencies. each generic clock runs from either clock source listed in the ?generic clock sources? table in the scif module configuration section. the selected source can optionally be divided by any even integer up to 512. each clock can be i ndependently enabled and disabled, and is also automatically disabled along with peripheral clocks by the sleep controller in the power manager. figure 13-11. generic clock generation 13.6.8.1 enabling a generic clock a generic clock is enabled by writing a one to the clock enable bit (cen) in the generic clock control register (gcctrl) . each generic clock can individually select a clock source by writing to the oscillator select field (oscsel). the sour ce clock can optionally be divided by writing a one to the divide enable bit (diven) and the divisio n factor field (div), resulting in the output frequency: where f src is the frequency of the selected source clock, and f gclk is the output frequency of the generic clock. 13.6.8.2 disabling a generic clock a generic clock is disabled by writing a zero to cen or entering a sleep mode that disables the pb clocks. in either case, the generic clock will be switched off on the first falling edge after the disabling event, to ensure that no glitches occu r. after cen has been written to zero, the bit will still read as one until the next fa lling edge occurs, and th e clock is switched off. when writing a zero to cen the other bits in gcctrl should not be changed until cen reads as zero, to avoid glitches on the generic clock. the generic cloc ks will be automatically re-enabled when waking from sleep. 13.6.8.3 changing clock frequency when changing the generic clock frequency by changing oscsel or div, the clock should be disabled before being re-enabled with the new cl ock source or division setting. this prevents glitches during the transition. divider oscsel generic clock div 0 1 diven mask cen sleep controller f src f gclk generic clock sources f gclk f src 2 div 1 + () ---------------------------- =
218 42023e?sam?07/2013 atsam4l8/l4/l2 13.6.8.4 generic clock allocation the generic clocks are allocated to different functions as shown in the ?generic clock allocation? table in the scif module configuration section. 13.6.9 interrupts the scif has the following interrupt sources: ? ae - access error: ? a protected scif register was accessed without first being correctly unlocked. ? rcfastlocklost - rcfastlock lost ? a to 1 transition on the pclksr.rcfastlocklost bit is detected. ? rcfastlock - rcfast lock ? a 0 to 1 transition on the pclksr.rcfastlock bit is detected. ? plllocklost - pll lock lost ? a to 1 transition on the pclksr.plllocklost bit is detected. ? plllock - pll lock ? a 0 to 1 transition on the pclksr.plllock bit is detected. ? dfll0rcs - dfll reference clock stopped: ? a 0 to 1 transition on the pclksr.dfllrcs bit is detected. ? dfll0rdy - dfll ready: ? a 0 to 1 transition on the pclksr.dfllrdy bit is detected. ? dfll0lockf - dfll locked on fine value: ? a 0 to 1 transition on the pclksr.dflllockf bit is detected. ? dfll0lockc - dfll locked on coarse value: ? a 0 to 1 transition on the pclksr.dflllockc bit is detected. ? oscrdy - oscready: ? a 0 to 1 transition on the pclksr.oscrdy bit is detected. the interrupt sources will generate an interrupt request if the corr esponding bit in the interrupt mask register is set. the interrupt sources are ored together to form one interrupt request. the scif will generate an interrupt request if at least one of the bits in the interrupt mask register (imr) is set. bits in imr are set by writing a one to the corresponding bit in the interrupt enable register (ier), and cleared by writing a one to the corresponding bit in the interrupt disable register (idr). the interrupt request remains active until the corresponding bit in the interrupt status register (isr) is cleared by writing a one to the corresponding bit in the interrupt clear register (icr). because all the interrupt sour ces are ored together, the interrupt request from the scif will remain acti ve until all the bits in isr are cleared.
219 42023e?sam?07/2013 atsam4l8/l4/l2 13.7 user interface table 13-3. scif register memory map offset register register name access reset 0x0000 interrupt enable register ier write only 0x00000000 0x0004 interrupt disable register idr write only 0x00000000 0x0008 interrupt mask register imr read only 0x00000000 0x000c interrupt status register isr read only 0x00000000 0x0010 interrupt clear register icr write only 0x00000000 0x0014 power and clocks status register pclksr read only 0x00000000 0x0018 unlock register unlock write only 0x00000000 0x001c chip specific configuration register cscr read/write 0x00000000 0x0020 oscillator control register oscctrl0 read/write 0x00000000 0x0024 pll0 control register pll0 read/write 0x00000000 0x0028 dfll0 config register dfll0conf read/write 0x00000000 0x002c dfll value register df ll0val read/write 0x00000000 0x0030 dfll0 multiplier register dfll0mul read/write 0x00000000 0x0034 dfll0 step register dfll0step read/write 0x00000000 0x0038 dfll0 spread spectrum generator control register dfll0ssg read/write 0x00000000 0x003c dfll0 ratio register dfll0ratio read only 0x00000000 0x0040 dfll0 synchronization regist er dfll0sync write only 0x00000000 0x0044 system rc oscillator cali bration register rccr read/write - (2) 0x0048 4/8/12mhz rc oscillator configuration register rcfastcfg read/write 0x00000000 0x004c 4/8/12mhz rc oscillator status register rcfastsr read only 0x00000000 0x0050 80mhz rc oscillator register rc80mcr read/write 0x00000000 0x0064 high resolution prescaler control register hrpcr read/write 0x0068 fractional prescaler control register fpcr read/write 0x006c fractional prescaler multiplier register fpmul read/write 0x0070 fractional prescaler di vider register fpdiv read/write 0x0074 generic clock control0 gcctrl0 read/write 0x00000000 0x0078 generic clock control1 gcctrl1 read/write 0x00000000 0x007c generic clock control2 gcctrl2 read/write 0x00000000 0x0080 generic clock control3 gcctrl3 read/write 0x00000000 0x0084 generic clock control4 gcctrl4 read/write 0x00000000 0x0088 generic clock control5 gcctrl5 read/write 0x00000000 0x008c generic clock control6 gcctrl6 read/write 0x00000000
220 42023e?sam?07/2013 atsam4l8/l4/l2 note: 1. the reset value is device specific. refer to the m odule configuration section at the end of this chapter. 2. the reset value of this register depends on factory calibration. 0x0090 generic clock control7 gcctrl7 read/write 0x00000000 0x0094 generic clock control8 gcctrl8 read/write 0x00000000 0x0098 generic clock control9 gcctrl9 read/write 0x00000000 0x009c generic clock control10 gcctrl10 read/write 0x00000000 0x00a0 generic clock control11 gcctrl11 read/write 0x00000000 0x03d8 4/8/12mhz rc oscillator vers ion register rcfastversion read-only - (1) 0x03dc generic clock prescaler version register gclkprescversion read-only - (1) 0x03e0 pll version register pllifaversion read-only - (1) 0x03e4 oscillator0 version regi ster oscifaversion read-only - (1) 0x03e8 dfll version register dfllifbversion read-only - (1) 0x03ec system rc oscillator version register rcoscifaversion read-only - (1) 0x03f4 80mhz rc oscillator versi on register rc80mversion read-only - (1) 0x03f8 generic clock version register gclkversion read-only - (1) 0x03fc scif version register version read-only - (1) table 13-3. scif register memory map offset register register name access reset
221 42023e?sam?07/2013 atsam4l8/l4/l2 13.7.1 interrupt enable register name: ier access type: write-only offset: 0x0000 reset value: 0x00000000 writing a zero to a bit in this register has no effect. writing a one to a bit in this register will set the corresponding bit in imr. 31 30 29 28 27 26 25 24 ae------- 23 22 21 20 19 18 17 16 ------ 15 14 13 12 11 10 9 8 - rcfastloc klost rcfastloc k - ---- 76543210 pll0lockl ost pll0lock - dfll0rcs dfll0rdy dfll0lock f dfll0lock c osc0rdy
222 42023e?sam?07/2013 atsam4l8/l4/l2 13.7.2 interrupt disable register name: idr access type: write-only offset: 0x0004 reset value: 0x00000000 writing a zero to a bit in this register has no effect. writing a one to a bit in this register will clear the corresponding bit in imr. 31 30 29 28 27 26 25 24 ae------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 - rcfastloc klost rcfastloc k ----- 76543210 pll0lockl ost pll0lock - dfll0rcs dfll0rdy dfll0lock f dfll0lock c osc0rdy
223 42023e?sam?07/2013 atsam4l8/l4/l2 13.7.3 interrupt mask register name: imr access type: read-only offset: 0x0008 reset value: 0x00000000 0: the corresponding interrupt is disabled. 1: the corresponding interrupt is enabled. a bit in this register is cleared when the corresponding bit in idr is written to one. a bit in this register is set when the corresponding bit in ier is written to one. 31 30 29 28 27 26 25 24 ae------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 - rcfastloc klost rcfastloc k ----- 76543210 pll0lockl ost pll0lock - dfll0rcs dfll0rdy dfll0lock f dfll0lock c osc0rdy
224 42023e?sam?07/2013 atsam4l8/l4/l2 13.7.4 interrupt status register name: isr access type: read-only offset: 0x000c reset value: 0x00000000 0: the corresponding interrupt is cleared. 1: the corresponding interrupt is pending. a bit in this register is cleared when the corresponding bit in icr is written to one. a bit in this register is set when the corresponding interrupt occurs. 31 30 29 28 27 26 25 24 ae------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 - rcfastloc klost rcfastloc k ----- 76543210 pll0lockl ost pll0lock - dfll0rcs dfll0rdy dfll0lock f dfll0lock c osc0rdy
225 42023e?sam?07/2013 atsam4l8/l4/l2 13.7.5 interrupt clear register name: icr access type: write-only offset: 0x0010 reset value: 0x00000000 writing a zero to a bit in this register has no effect. writing a one to a bit in this register will clear the corresponding bit in isr. 31 30 29 28 27 26 25 24 ae------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 - rcfastloc klost rcfastloc k ----- 76543210 pll0lockl ost pll0lock - dfll0rcs dfll0rdy dfll0lock f dfll0lock c osc0rdy
226 42023e?sam?07/2013 atsam4l8/l4/l2 13.7.6 power and clocks status register name: pclksr access type: read-only offset: 0x0014 reset value: 0x00000000 ? rcfastlocklost: rcfast lock lost value 0: rcfast has not lost it?s lock or has never been enabled. 1: rcfast has lost it?s lock. ? rcfastlock: rcfast locked on accurate value 0: rcfast is not locked on accurate value. 1: rcfast is locked on accurate value, the tuning procedure is completed and the current count is within the rcfastcfg.lockmargin of the target count. ? pll0locklost: pll0 lock lost value 0: pll0 has not lost it?s lock or has never been enabled. 1: pll0 has lost it?s lock, either by disabling the pll0 or due to faulty operation. ? pll0lock: pll0 locked on accurate value 0: pll0 is unlocked on accurate value. 1: pll0 is locked on accurate value, and is ready to be selected as clock source with an accurate output clock. ? dfll0rcs: dfll0 reference clock stopped 0: the dfll reference clock is running, or has never been enabled. 1: the dfll reference clock has stopped or is too slow. ? dfll0rdy: dfll0 synchronization ready 0: read or write to dfll registers is invalid. 1: read or write to dfll registers is valid. ? dfll0lockf: dfll0 locked on fine value 0: dfll is unlocked on fine value. 1: dfll is locked on fine value, and is ready to be selected as clock source with a high accuracy on the output clock. ? dfll0lockc: dfll0 lock ed on coarse value 0: dfll is unlocked on coarse value. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 - ------ 15 14 13 12 11 10 9 8 - rcfastloc klost rcfastloc k ----- 76543210 pll0lockl ost pll0lock - dfll0rcs dfll0rdy dfll0lock f dfll0lock c osc0rdy
227 42023e?sam?07/2013 atsam4l8/l4/l2 1: dfll is locked on coarse value, and is ready to be selected as clock source with medium accuracy on the output clock. ? osc0rdy: osc0 ready 0: oscillator not enabled or not ready. 1: oscillator is stable and ready to be used as clock source.
228 42023e?sam?07/2013 atsam4l8/l4/l2 13.7.7 unlock register name: unlock access type: write-only offset: 0x0018 reset value: 0x00000000 to unlock a write protected register, first write to the unlock r egister with the address of the re gister to unlock in the addr field and 0xaa in the key field. then, in the next pb ac cess write to the register specified in the addr field. ? key: unlock key write this bit field to 0xaa to enable unlock. ? addr: unlock address write the address offset of the register to unlock to this field. 31 30 29 28 27 26 25 24 key 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 ------ addr[9:8] 76543210 addr[7:0]
229 42023e?sam?07/2013 atsam4l8/l4/l2 13.7.8 oscillator control register name: oscctrln access type: read/write reset value: 0x00000000 ? oscen: oscillator enable 0: the oscillator is disabled. 1: the oscillator is enabled. ? startup: oscillator start-up time select start-up time for the oscillator. refer to the ?oscillato r startup time? table in the scif module configuration section for details. ? agc: automatic gain control for test purposes. ? gain: gain selects the gain for the oscillator. refer to the ?oscillator gain settings? table in the scif module configuration section for details. ? mode: oscillator mode 0: external clock connected on xin. xout can be used as general-purpose i/o (no crystal). 1: crystal is connected to xin/xout. note that this register is protected by a lock. to write to th is register the unlock register has to be written first. refer to section 13.7.7 ?unlock register? on page 228 for details. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------oscen 15 14 13 12 11 10 9 8 ---- startup[3:0] 76543210 - - - agc gain[1:0] mode
230 42023e?sam?07/2013 atsam4l8/l4/l2 13.7.9 pll control register name: plln access type: read/write reset value: 0x00000000 ? pllcount: pll count specifies the number of rcsys clock cycles before isr.plllockn will be set after pl ln has been written, or after plln has been automatically re-enabled after exiting a sleep mode. ? pllmul: pll multiply factor ? plldiv: pll division factor these fields determine the ratio of the pll ou tput frequency to the source oscillator frequency: f vco = (pllmul+1)/plldiv ? f ref if plldiv >0 f vco = 2?(pllmul+1) ? f ref if plldiv = 0 note that the pllmul field should always be greater than 1 or the behavior of the pll will be undefined. ? pllopt: pll option pllopt[0]: selects the vco frequency range (f vco ). 0: 80mhz 231 42023e?sam?07/2013 atsam4l8/l4/l2 ? pllen: pll enable 0: pll is disabled. 1: pll is enabled. note that it is not possible to change an y of the pll configuration bits when the pl l is enabled, any write to plln while the p ll is enabled will be discarded. note that this register is protected by a lock. to write to th is register the unlock register has to be written first. refer to section 13.7.7 ?unlock register? on page 228 for details.
232 42023e?sam?07/2013 atsam4l8/l4/l2 13.7.10 dfllx configuration register name: dfllxconf access type: read/write reset value: 0x0x100000 (1) note: 1. the reset value of calb depends on factory calibration. ? calib: calibration value sets the calibration value for the dfllx. ? fcd: fuse calibration done set to 1 when calib field has been updated by the flash fuses after a reset. 0: the flash calibration will be redone after any reset 1: the flash calibration will only be redone after a power-on reset. ? range: range value set the value of the range calibration register. refer to the table dfll frequency range in the open loop operation section. ? qldis: quick lock disable 0: quick lock is enabled. 1: quick lock is disabled. ? ccdis: chill cycle disable 0: chill cycle is enabled. 1: chill cycle is disabled. ? llaw: lose lock after wake 0: locks will not be lost after waking up from sleep modes. 1: locks will be lost after waking up from sle ep modes where the dfll clock has been stopped. ? stable: stable dfll frequency 0: fine calibration tracks changes in output frequency. 1: fine calibration register value will be fixed after fine lock. ? mode: mode selection 0: dfll is in open loop operation. 1: dfll is in closed loop operation. ? en: enable 0: dfll is disabled. 1: dfll is enabled. note that this register is protected by a lock. to write to th is register the unlock register has to be written first. refer to section 13.7.7 ?unlock register? on page 228 for details. 31 30 29 28 27 26 25 24 - -- -calib 23 22 21 20 19 18 17 16 fcd----- range 15 14 13 12 11 10 9 8 -- ----- - 76543210 - qldis ccdis - llaw stable mode en
233 42023e?sam?07/2013 atsam4l8/l4/l2 13.7.11 dfllx value register name: dfllxval access type: read/write reset value: 0x00000000 ? coarse: coarse value set the value of the coarse calibration register. in closed loop mode, this field is read-only. ? fine: fine value set the value of the fine calibration register. in closed loop mode, this field is read-only. note that this register is protected by a lock. to write to th is register the unlock register has to be written first. refer to section 13.7.7 ?unlock register? on page 228 for details. 31 30 29 28 27 26 25 24 - -- - -- -- 23 22 21 20 19 18 17 16 --- coarse 15 14 13 12 11 10 9 8 -- ----- - 76543210 fine
234 42023e?sam?07/2013 atsam4l8/l4/l2 13.7.12 dfllx multiplier register name: dfllxmul access type: read/write reset value: 0x00000000 ? mul: dfll multiply factor this field determines the ratio of the clk_dfllx ou tput frequency to the clk_ dfllx_ref input frequency. note that this register is protected by a lock. to write to th is register the unlock register has to be written first. refer to section 13.7.7 ?unlock register? on page 228 for details. 31 30 29 28 27 26 25 24 - ------- 23 22 21 20 19 18 17 16 - ------- 15 14 13 12 11 10 9 8 mul[15:8] 76543210 mul[7:0]
235 42023e?sam?07/2013 atsam4l8/l4/l2 13.7.13 dfllx maximum step register name: dfllxstep access type: read/write reset value: 0x00000000 ? cstep: coarse maximum step this indicates the maximum step size during coarse adjustment in closed loop mode. when adjusting to a new frequency, the expected overshoot of that freq uency depends on this step size. ? fstep: fine maximum step this indicates the maximum step size during fine adjustment in closed loop mode. when adjusting to a new frequency, the expected overshoot of that freq uency depends on this step size. note that this register is protected by a lock. to write to th is register the unlock register has to be written first. refer to section 13.7.7 ?unlock register? on page 228 for details. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 --- cstep 15 14 13 12 11 10 9 8 -------- 76543210 fstep
236 42023e?sam?07/2013 atsam4l8/l4/l2 13.7.14 dfllx spread spectrum generator control register name: dfllxssg access type: read/write reset value: 0x00000000 ? stepsize: ssg step size selects the step size of the spread spectrum. if zero or one, the value added to the fine bits will be incremented/decremented with one on every positive edge of the input clock. if n > 1, the value added to the fine bi ts will be incremented/decremented with n on every positive edge of the input clock. ? amplitude: ssg amplitude selects the amplitude of the spread spectrum. if zero, only the lsb of the fine bits will be affected. if one, the sequence {1, 0, -1, 0} will be added to fine bits, etc. ? prbs: pseudo random bit sequence 0: each spread spectrum frequency is applied at constant intervals 1: each spread spectrum frequency is applied at pseudo-random intervals ? en: enable 0: ssg is disabled. 1: ssg is enabled. note that this register is protected by a lock. to write to th is register the unlock register has to be written first. refer to section 13.7.7 ?unlock register? on page 228 for details. 31 30 29 28 27 26 25 24 - ------- 23 22 21 20 19 18 17 16 - - - stepsize 15 14 13 12 11 10 9 8 - - - amplitude 76543210 ------prbsen
237 42023e?sam?07/2013 atsam4l8/l4/l2 13.7.15 dfllx ratio register name: dfllxratio access type: read-only reset value: 0x00000000 ? ratiodiff: multiplica tion ratio difference in closed loop mode, this field indicates the error in the ratio between the clk_dfllx frequ ency and the target frequency. this value is not updated in open loop mode, and should be considered invalid in that case. 31 30 29 28 27 26 25 24 - ------- 23 22 21 20 19 18 17 16 - ------- 15 14 13 12 11 10 9 8 ratiodiff[15:8] 76543210 ratiodiff[7:0]
238 42023e?sam?07/2013 atsam4l8/l4/l2 13.7.16 dfllx synchronization register name: dfllxsync access type: write-only reset value: 0x00000000 ? sync: synchronization to be able to read the current value of dfllxval or dfllx ratio, this bit must be written to one. the updated value are available in dfllxval or dfllxratio when pclksr.dfll0rdy is set. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------- 76543210 -------sync
239 42023e?sam?07/2013 atsam4l8/l4/l2 13.7.17 system rc oscillator calibration register name: rccr access type: read/write reset value: - ? fcd: flash calibration done 0: the flash calibration will be redone after any reset. 1: the flash calibration will only be redone after a power-on reset. this bit is cleared after a por. this bit is set when the calib field has been updated by the flash fuses after a reset. ? calib: calibration value calibration value for the system rc oscillator (rcsys). note that this register is protected by a lock. to write to th is register the unlock register has to be written first. refer to section 13.7.7 ?unlock register? on page 228 for details. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------fcd 15 14 13 12 11 10 9 8 ------ calib[9:8] 76543210 calib[7:0]
240 42023e?sam?07/2013 atsam4l8/l4/l2 13.7.18 4/8/12mhz rc oscillator configuration register name: rcfastcfg access type: read/write reset value: 0x00000000 ? calib: oscillator calibration value writing a value to this field sets the oscillator trim value. a small value will produce a fast rcfast clock and a big value wi ll produce a slow clock. if the tuner is enabled, writing to this field will cause the tuner to start tuning from the written valu e. ? lockmargin: accepted count error for lock writing a value to this field defines the maximum absolute value of the current count error with respect to the theoretical cou nt that will be trigger th e rcfastlock condition: if abs(count - count_theor) <= lockmargin, then rcfastlo ck is set, otherwise rcfastlocklost is set, with count_theor = 122 x (1 + frange) << nbperiods. ? frange: frequency range 00: 4mhz range selected. 01: 8mhz range selected. 10: 12mhz range selected. 11: reserved. ? fcd: rcfast fuse calibration done always read as 1 (read only). set to 1 when the calib field has been updated by the flash fuses after a reset (read only). 0: calibration from flash fuses has not been loaded. cali bration from flash fuses will be redone after any reset. 1: calibration from flash fuses has been loaded. calibration from flash fuses will only be redone after a power-on reset. ? nbperiods: number of 32khz periods writing a value to this field defines the number of periods of the 32khz clock used to co mpare the rcfast clock output. a higher value increases the tuner precision and smoothes the calibration adjustments. ? jitmode: jitter mode 0: the rcfast trim value is only updated when the rcfastlocklo st is set; it is kept stab le as long as the rcfastlock condition is set. 1: the rcfast trim value is continuously updated. ? tuneen: tuner enable 0: tuner is not enabled, and the rcfast operates in open loop mode. 1: tuner is enabled, and the rcfast operates in closed loop mode. ? en: oscillator enable 0: the rcfast clock is disabled, and the output clock is stopped. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -calib 15 14 13 12 11 10 9 8 lockmargin - - frange 76543210 fcd nbperiods - jitmode tuneen en
241 42023e?sam?07/2013 atsam4l8/l4/l2 1: the rcfast clock is enabled, and the output clock is running. note that this register is protected by a lock. to write to th is register the unlock register has to be written first. refer to section 13.7.7 ?unlock register? on page 228 for details.
242 42023e?sam?07/2013 atsam4l8/l4/l2 13.7.19 4/8/12mhz rc oscillator status register name: rcfastsr access type: read-only reset value: 0x00000000 ? updated: current trim value updated this field toggles each time the tuning procedure completes. ? locklost: lock lost this field indicates that the current count is outside rcfastcf g.lockmargin from the theoreti cal count. it is updated after each tuning procedure. ? lock: lock this field indicates that the current count is within rcfastcfg. lockmargin of the theoretical c ount. it is updated after each tuning procedure. ? sign: sign of current count error this field returns the sign of the current difference between t he current count and the theoretical count. it is updated after each tuning procedure. ? cnterr: current count error this field returns the current absolute difference between the cu rrent count and the theoretical count. it is updated after eac h tuning procedure. ? curtrim: current trim value this field returns the current trim value used by the rcfast oscillator. it is updated after each tuning procedure. 31 30 29 28 27 26 25 24 updated-----locklostlost 23 22 21 20 19 18 17 16 - - sign cnterr 15 14 13 12 11 10 9 8 -------- 76543210 - curtrim
243 42023e?sam?07/2013 atsam4l8/l4/l2 13.7.20 80mhz rc oscillator control register name: rc80mcr access type: read/write reset value: 0x00000000 ? calib: calibration value calibration value for the rc oscillator (read-only). ? fcd: flash calibration done ? en: enable 0: the oscillator is disabled. 1: the oscillator is enabled. 31 30 29 28 27 26 25 24 ------ 23 22 21 20 19 18 17 16 ------ calib 15 14 13 12 11 10 9 8 ----- - 76543210 fcd --- - en
244 42023e?sam?07/2013 atsam4l8/l4/l2 13.7.21 high resolution prescaler control register name: hrpcr access type: read/write reset value: 0x00000000 ? hrcount: high resolution counter specify the input clock period to count to generate the output clock edge. hrcount can be written to dynamically in order to tune the hrpclk frequency on-the-go. ? cksel: clock in put selection this field selects the clock input for the prescaler. see the ?hrp clock sources? table in the scif module configuration sectio n for details. it must not be changed if the hrpen is one. ? hrpen: high resolution prescaler enable 0: the high resolution prescaler is disabled. 1: the high resolution prescaler is enabled. 31 30 29 28 27 26 25 24 hrcount[23:16] 23 22 21 20 19 18 17 16 hrcount[15:8] 15 14 13 12 11 10 9 8 hrcount[7:0] 76543210 - - - - cksel hrpen
245 42023e?sam?07/2013 atsam4l8/l4/l2 13.7.22 fractional prescaler control register name: fpcr access type: read/write reset value: 0x00000000 ? cksel: clock in put selection this field selects the clock input for the prescaler. see the ?fp clock sources? table in the scif module configuration section for details. it must not be changed if the fpen is one. ? fpen: high resolution prescaler enable 0: the fractional prescaler is disabled. 1: the fractional prescaler is enabled. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------- 76543210 - - - - cksel fpen
246 42023e?sam?07/2013 atsam4l8/l4/l2 13.7.23 fractional prescaler mul register name: fpmul access type: read/write reset value: 0x00000000 ? fpmul: fractional prescal er multiplication factor this field selects the multiplication factor for the prescaler. notice that fpmul is always smaller than fpdiv. fpmul can be written to dynamically in order to tune the fpclk frequency on-the-go. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 fpmul[15:8] 76543210 fpmul[7:0]
247 42023e?sam?07/2013 atsam4l8/l4/l2 13.7.24 fractional prescaler div register name: fpdiv access type: read/write reset value: 0x00000000 ? fpdiv: fractional prescaler division factor this field selects the divisi on factor for the prescaler. notice that fpmul must be smaller than fpdiv. fpdiv can be wr itten to dynamically in order to tune the fpclk frequency on- the-go. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 fpdiv[15:8] 76543210 fpdiv[7:0]
248 42023e?sam?07/2013 atsam4l8/l4/l2 13.7.25 generic clock control name: gcctrl access type: read/write reset value: 0x00000000 there is one gcctrl register per generic clock in the design. ? div: division factor the number of div bits for each generic clock is as shown in the ?generic clock number of div bi ts? table in the scif module configuration section. ? oscsel: oscillator select selects the source clock for the generic clock. refer to the ?ge neric clock sources? table in the scif module configuration section. ? diven: divide enable 0: the generic clock equals the undivided source clock. 1: the generic clock equals the source clock divided by 2*(div+1). ? cen: clock enable 0: the generic clock is disabled. 1: the generic clock is enabled. 31 30 29 28 27 26 25 24 div[15:8] 23 22 21 20 19 18 17 16 div[7:0] 15 14 13 12 11 10 9 8 - - - oscsel[4:0] 76543210 ------divencen
249 42023e?sam?07/2013 atsam4l8/l4/l2 13.7.26 4/8/12mhz rc oscillator version register name: rcfastversion access type: read-only offset: 0x03d8 reset value: - ? variant: variant number reserved. no functionality associated. ? version: version number version number of the module. no functionality associated. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 ---- variant 15 14 13 12 11 10 9 8 - - - - version[11:8] 76543210 version[7:0]
250 42023e?sam?07/2013 atsam4l8/l4/l2 13.7.27 generic clock prescalers version register name: gclkprescversion access type: read-only offset: 0x03dc reset value: - ? variant: variant number reserved. no functionality associated. ? version: version number version number of the module. no functionality associated. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 ---- variant 15 14 13 12 11 10 9 8 - - - - version[11:8] 76543210 version[7:0]
251 42023e?sam?07/2013 atsam4l8/l4/l2 13.7.28 pll version register name: pllifaversion access type: read-only offset: 0x03e0 reset value: - ? variant: variant number reserved. no functionality associated. ? version: version number version number of the module. no functionality associated. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 ---- variant 15 14 13 12 11 10 9 8 - - - - version[11:8] 76543210 version[7:0]
252 42023e?sam?07/2013 atsam4l8/l4/l2 13.7.29 oscillator 0 version register name: oscifaversion access type: read-only offset: 0x03e4 reset value: - ? variant: variant number reserved. no functionality associated. ? version: version number version number of the module. no functionality associated. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 ---- variant 15 14 13 12 11 10 9 8 - - - - version[11:8] 76543210 version[7:0]
253 42023e?sam?07/2013 atsam4l8/l4/l2 13.7.30 digital frequency locked loop version register name: dfllifbversion access type: read-only offset: 0x03e8 reset value: - ? variant: variant number reserved. no functionality associated. ? version: version number version number of the module. no functionality associated. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 ---- variant 15 14 13 12 11 10 9 8 - - - - version[11:8] 76543210 version[7:0]
254 42023e?sam?07/2013 atsam4l8/l4/l2 13.7.31 rc oscillator version register name: rcoscifaversion access type: read-only offset: 0x03ec reset value: - ? variant: variant number reserved. no functionality associated. ? version: version number version number of the module. no functionality associated. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 ---- variant 15 14 13 12 11 10 9 8 - - - - version[11:8] 76543210 version[7:0]
255 42023e?sam?07/2013 atsam4l8/l4/l2 13.7.32 80mhz rc oscillator version register name: rc80mversion access type: read-only offset: 0x03f4 reset value: - ? variant: variant number reserved. no functionality associated. ? version: version number version number of the module. no functionality associated. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 ---- variant 15 14 13 12 11 10 9 8 - - - - version[11:8] 76543210 version[7:0]
256 42023e?sam?07/2013 atsam4l8/l4/l2 13.7.33 generic clock version register name: gclkifversion access type: read-only offset: 0x03f8 reset value: - ? variant: variant number reserved. no functionality associated. ? version: version number version number of the module. no functionality associated. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 ---- variant 15 14 13 12 11 10 9 8 - - - - version[11:8] 76543210 version[7:0]
257 42023e?sam?07/2013 atsam4l8/l4/l2 13.7.34 scif version register name: version access type: read-only offset: 0x03fc reset value: - ? variant: variant number reserved. no functionality associated. ? version: version number version number of the module. no functionality associated. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 ---- variant 15 14 13 12 11 10 9 8 - - - - version[11:0] 76543210 version[7:0]
258 42023e?sam?07/2013 atsam4l8/l4/l2 13.8 module configuration the specific configuration for each scif instance is listed in the following tables.the module bus clocks listed here are connected to the system bus clocks. refer to section 10. ?power manager (pm)? on page 108 for details. table 13-4. scif clock name module name clock name description scif clk_scif clock for the scif bus interface table 13-5. oscillator startup times startup number of system rc oscillator clock cycle approximative equivalent time (rcsys = 115 khz) 00 0 1 64 557 us 2128 1.1ms 32048 18ms 44096 36ms 58192 71ms 6 16384 143 ms 7 32768 285 ms 8 4 35 us 9 8 70 us 10 16 139 us 11 32 278 us 12 256 2.2 ms 13 512 4.5 ms 14 1024 8.9 ms 15 32768 285 ms table 13-6. oscillator gain settings gain[1:0] function 0 oscillator is used with gain g0 (xin from 0.6mhz to 2.0mhz) 1 oscillator is used with gain g1 (xin from 2.0mhz to 4.0mhz) 2 oscillator is used with gain g2 (xin from 4.0mhz to 8.0mhz) 3 oscillator is used with gain g3 (xin from 8.0mhz to 16.0mhz) 4 oscillator is used with gain g4 (xin from 16.0mhz to 30.0mhz)
259 42023e?sam?07/2013 atsam4l8/l4/l2 in atsam4l8/l4/l2, there are 12 generic clocks. these are allocated to different functions as shown in table 13-7 . table 13-7. generic clock allocation clock number function 0 dfllif main reference and gclk0 pin (clk_dfllif_ref) 1 dfllif dithering and ssg reference and gclk1 pin (clk_dfllif_dither) 2 ast and gclk2 pin 3 catb and gclk3 pin 4 aesa 5 gloc, tc0 and rc32kifb_ref 6 abdacb and iisc 7 usbc 8 tc1 and pevc[0] 9 pll0 and pevc[1] 10 adcife 11 master generic clock. can be used as source for other generic clocks. table 13-8. generic clock sources oscsel clock/oscillator description 0 rcsys system rc oscillator clock 1 osc32k output clock from osc32k 2 dfll0 output clock from dfll0 3 osc0 output clock from oscillator0 4 rc80m output from 80mhz rcosc 5 rcfast output from 4,8,12mhz rcfast 6 rc1m output from 1mhz rc1m 7 clk_cpu the clock the cpu runs on 8 clk_hsb high speed bus clock 9 clk_pba peripheral bus a clock 10 clk_pbb peripheral bus b clock 11 clk_pbc peripheral bus c clock 12 clk_pbd peripheral bus d clock 13 rc32k output from 32khz rcosc 14 reserved
260 42023e?sam?07/2013 atsam4l8/l4/l2 . 15 clk_1k 1khz output clock from osc32k 16 pll0 output clock from pll0 17 hrp high resolution prescaler output 18 fp fractionnal prescaler output 19-20 gclk_in[0-1] gclk_in[0-1] pins, digital clock input 21 gclk11 generic clock 11. can not be use as input to itself. 22-31 reserved table 13-9. pll clock sources pllosc clock/oscillator description 0 osc0 output clock from oscillator0 1 gclk9 generic clock 9 2-3 reserved table 13-10. generic clock number of div bits generic clock number of div bits 08 18 28 38 48 58 68 78 88 98 10 8 11 16 table 13-8. generic clock sources oscsel clock/oscillator description
261 42023e?sam?07/2013 atsam4l8/l4/l2 table 13-11. hrp and fp clock sources cksel clock/oscillator description 0 osc0 output clock from oscillator0 1 pll0 output clock from pll0 2 dfll0 output clock from dfll0 3 reserved 4 rc80m output from 80mhz rcosc table 13-12. register reset values register reset value rcfastversion 0x00000200 gclkprescversion 0x00000102 pllifaversion 0x00000112 oscifaversion 0x00000114 dfllifbversion 0x00000110 rcoscifaversion 0x00000114 rc80mversion 0x00000100 gclkifversion 0x00000112 version 0x00000130
262 42023e?sam?07/2013 atsam4l8/l4/l2 14. flash controller (flashcalw) rev: 1.1.0.1 14.1 features ? controls on-chip flash memory ? supports 0 and 1 wait state bus access ? flash read-standby mode to achieve very low power flash operation ? unified direct mapped picocache to minimize flash active power and improve performance ? 32-bit hsb interface for reads from flash and writes to page buffer ? 32-bit pb interface for issuing commands to and configuratio n of the controller ? 32-bit hsb interface for reads and writes to the picocache ram when it is disabled ? flash memory is divided into 16 regions that can be individually protected or unprotected ? supports reads and writes of general-purpose non volatile memory (nvm) bits ? supports reads and writes of additional nvm pages ? supports strong device protection 14.2 overview the flash controller (flashcalw) interfaces the on-chip flash memory with the 32-bit internal hsb bus. the controller manages the reading, writing, erasing, locking, and unlocking sequences. to minimize power consumption, the module is tigthly coupled to a direct mapped cache resulting in a significant decrease of the flash active power consumption and also in a per- formance increase when running with one wait state.
263 42023e?sam?07/2013 atsam4l8/l4/l2 14.3 block diagram 14.4 product dependencies in order to use this module, other parts of the system must be configured correctly, as described below. 14.4.1 power management if the cpu enters a power save mode that disables clocks used by the flashcalw, the flashcalw will stop functioning a nd resume operation after the system wakes up from power save mode. write and erase operation are not allowed when the device in power scaling configuration 1 (bpm.pmcon.ps=1) 14.4.2 clocks the flashcalw has three bus clocks connected: two high speed bus clock (clk_flashcalw_ahb and clk_hramc1_ ahb) and one peripheral bus clock (clk_flashcalw_apb). these clocks are generat ed by the power mana ger. both clocks are enabled at reset, and can be disabled by writing to the power manager. the user has to ensure that clk_flashcalw_ahb is not turned off before reading the flash or writing the pagebuffer cortex-m4 picocache 2 kb ram 256 kb flash hmatrix cortex-m4 picocache 2 kb ram 256 kb flash hmatrix i/d ahb system ahb flash controller flash controller i/d ahb picocache disabled picocache enabled hramc1
264 42023e?sam?07/2013 atsam4l8/l4/l2 and that clk_flashca lw_apb is not turned off before accessing the flash calw configu- ration and control registers. failin g to do so may deadlock the bus. 14.4.3 interrupts the flashcalw interrupt request lines are connected to the nvic. using the flashcalw interrupts requires that it is programmed first. 14.4.4 debug operation when an external debugger forces the cpu into debug mode, the flashcalw continues nor- mal operation. if the flashcalw is configured in a way that requires it to be periodically serviced by the cpu through interrupts or similar, improper operation or data loss may result during debugging.
265 42023e?sam?07/2013 atsam4l8/l4/l2 14.5 functional description 14.5.1 bus interfaces the flashcalw has three bus interfaces, two high speed bus (hsb) interfaces for: ? reads from the flash memory and writes to the page buffer ? read/write in the picocache inte rnal ram when it is disabled and one peripheral bus (pb) interface for issuing commands and reading status from the controller.
266 42023e?sam?07/2013 atsam4l8/l4/l2 14.5.2 flash memory organization the flash memory is divided into a set of pages. a page is the basic unit addressed when pro- gramming the flash. a page consists of several words. the pages are grouped into 16 regions of equal size. _ahbeach of these regions can be locked by a dedicated fuse bit, protecting it from accidental modification. ? p pages ( flash_p ) ? w bytes in each page and in the page buffer ( flash_w ) ? pw bytes in total ( flash_pw ) ? f general-purpose fuse bits ( flash_f ), used as region lock bits and for other device-specific purposes ? security fuses ? 1 user page 14.5.3 user page the user page is an additional page, outside the regular flash array, that can be used to store various data, such as calibration data and serial numbers. this page is not erased by regular chip erase. the user page can only be written and erased by a special set of commands. read accesses to the user page are performed just as any other read accesses to the flash. the address map of the user page is given in figure 14-2 on page 268 . 14.5.4 read operations the on-chip flash memory is typically used for storing instructions to be executed by the cpu. the cpu will address instructions using th e hsb bus, and the flashcalw will access the flash memory and return the addressed 32-bit word. in systems where the hsb clock period is slower than the access time of the flash memory, the flashcalw can operate in 0 wait state mode, and output one 32-bit word on the bus per clock cycle. if the clock frequency allows, the user should use 0 wait state mode, because this gives the highest performance as no stall cycles are encountered. the flashcalw can also operate in systems w here the hsb bus clock period is faster than the access speed of the flash memory. wait state support and a read granularity of 64 bits ensure efficiency in such systems. performance for systems with high clock freque ncy is increased since the internal read word width of the flash memory is 64 bits. when a 32-bit word is to be addressed, the word itself and also the other word in the same 64-bit location is read. the user can select the wait states required by writing to the fws field in the flash control reg- ister (fcr). it is the responsibility of the user to select a number of wait states compatible with the clock frequency and timing characteristics of the flash memory. in 0ws mode, no wait states are encountered on any flash read operations. in 1 ws mode, one stall cycle is encountered every 64-bit aligned transfer. if the picocache is enabled and there is a hit, then it will service th e transfer with no penalty. the flash controller address space is displayed in figure 14-1 . the memory space between address pw and the user page is reserved, and reading addresses in this space returns an
267 42023e?sam?07/2013 atsam4l8/l4/l2 undefined result. the user page is permanently mapped to an offset of 0x00800000 from the start address of the flash memory. figure 14-1. memory map for the flash memories table 14-1. user page addresses memory type start address, byte sized size main array 0 pw bytes user 0x00800000 w bytes 0 pw reserved flash data array reserved user page flash with user page 0x0080 0000 all addresses are byte addresses flash base address offset from base address
268 42023e?sam?07/2013 atsam4l8/l4/l2 figure 14-2. memory map for the flash memories 14.5.5 high speed read mode the flash provides a high speed read mode, offering slightly higher flash read speed at the cost of higher power consumption. two dedicated commands, high speed read mode enable (hsen) and high speed read mode disable (hsdis) control the speed mode. the high speed mode (hsmode) bit in the flash status register (fsr) shows which mode the flash is in. after reset, the high speed mode is disabled, and must be manually enabled if the user wants to. refer to section 42. ?electrical characteristics? on page 1120 at the end of this datasheet for details on the maximum clock frequencies in normal and high speed read mode. 0 pw reserved flash data array reserved user page flash with user page 0x0080 0000 all addresses are byte addresses flash base address offset from base address
269 42023e?sam?07/2013 atsam4l8/l4/l2 figure 14-3. high speed mode 14.5.6 quick page read a dedicated command, quick page read (qpr), is provided to read all words in an addressed page. all bits in all words in this page are and?e d together, returning a 1-bi t result. this result is placed in the quick page read result (qprr) bi t in flash status register (fsr). the qpr command is useful to check that a page is in an erased state. the qpr instruction is much faster than performing the erased-page check using a regular software subroutine. 14.5.7 quick user page read a dedicated command, quick user page read (qp rup), is provided to read all words in the user page. all bits in all word s in this page are and?ed together, returning a 1-bit result. this result is placed in the quick page read result (qprr) bit in flash status register (fsr). the qprup command is useful to check that a page is in an erased state. the qprup instruction is much faster than performing the erased-page check using a regular software subroutine. frequency frequency limit for 0 wait state operation n or mal hig h speed mode 1 wait state 0 wait state
270 42023e?sam?07/2013 atsam4l8/l4/l2 14.5.8 page buffer operations the flash memory has a write and erase granularity of one page; data is written and erased in chunks of one page. when programming a page, the user must first write the new data into the page buffer. the contents of the entire page buffer is copied into the desired page in flash memory when the user issues the write page command, refer to section 14.6.1 on page 275 . in order to program data into flash page y, write the desired data to locations y0 to y31 in the regular flash memory map. writ ing to an address a in the fl ash memory map will not update the flash memory, but will inst ead update location a% 32 in the page buffer. th e pagen field in the flash command (fcmd) register will at the same time be up dated with the value a/32. figure 14-4. mapping from page buffer to flash internally, the flash memory stores data in 64-bit doublewords. therefore, the native data size of the page buffer is also a 64-bit doubleword. all locations shown in figure 14-4 are therefore doubleword locations. since the hsb bus only has a 32-bit data width, two 32-bit hsb transfers must be performed to write a 64-bit doubleword into the page buffer. the flashcalw has logic to combine two 32-bit hsb transfers into a 64-b it data before writing this 64-bit data into the page buffer. this logic requires the word with the low address to be written to the hsb bus before the word with the high address. to exemplify, to write a 64-bit value to doubleword x0 residing in page x, first write a 32-bit word to the byte address pointing to address x0, thereafter write a word to the byte address pointing to address (x0+4). the page buffer is word-addressable and should only be written with aligned word transfers, never with byte or halfword transfers. the page buffer cannot be read. z3 z2 z1 z0 z7 z6 z5 z4 z11 z10 z9 z8 z15 z14 z13 z12 z19 z18 z17 z16 z23 z22 z21 z20 z27 z26 z25 z24 z31 z30 z29 z28 y3 y2 y1 y0 y7 y6 y5 y4 y11 y10 y9 y8 y15 y14 y13 y12 y19 y18 y17 y16 y23 y22 y21 y20 y27 y26 y25 y24 y31 y30 y29 y28 x3 x2 x1 x0 x7 x6 x5 x4 x11 x10 x9 x8 x15 x14 x13 x12 x19 x18 x17 x16 x23 x22 x21 x20 x27 x26 x25 x24 x31 x30 x29 x28 3 2 1 0 7 6 5 4 11 10 9 8 15 14 13 12 19 18 17 16 23 22 21 20 27 26 25 24 31 30 29 28 page x page y page z page buffer 64-bit data flash all locations are doubleword locations
271 42023e?sam?07/2013 atsam4l8/l4/l2 the page buffer is also used for writes to the user page. page buffer write operations are performed with 4 wait states. any accesses attempted to the flashcalw on the hsb bus during these cycles will be automatically stalled. writing to the page buffer can only change page buffer bits from one to zero, i.e. writing 0xaaaaaaaa to a page buffer loca tion that has the value 0x 00000000 will not change the page buffer value. the only way to change a bit from zero to one is to erase the entire page buffer with the clear page buffer command. the page buffer is not automatically reset after a page write. the user should do this manually by issuing the clear page buffer flash command. this can be done after a page write, or before the page buffer is loaded with data to be stored to the flash page.
272 42023e?sam?07/2013 atsam4l8/l4/l2 14.5.9 picocache description 14.5.9.1 overview the picocache is an unified direct mapped cache controller. it integrates a controller, a tag directory, a data memory, a metadata memory and a configuration interface. when it is not acti- vated, the cache memory is accessible as a supplementary ram connected on the bus matrix. note that for security reasons, this memory is cleared by a chip erase operation. 14.5.9.2 cache operation on reset, the cache controller data entries are all invalidated and the cache is disabled. the cache is transparent to processor operations making flash access timings predicatable. the cache controller is activated through the use of its configuration registers. use the following sequence to enable the cache controller 1. verify that the cache controller is disabled , reading the value of the csts (cache sta- tus) field of the sr register. 2. enable the cache controller writing one to cen (cache enable) field of the ctrl register. 14.5.9.3 cache invalidate by line operation when an invalidate by line comman d is issued the cache controller reset the valid bit information of the decoded cache line. as the line is no longer valid the replacement counter points to that line. use the following sequence to invalidate one line of cache: 1. disable the cache controller writing 0 to the cen field of the ctrl register. 2. check csts field of the sr to verify that the cache is successfully disabled. 3. perform an invalidate by line writing the field index in the maint1 register. 4. enable the cache controller writing 1 to the cen field of the ctrl register. 14.5.9.4 cache invalid ate all operation use the following sequence to invalidate all cache entries: 1. write 1 to the invall field of the maint0 register. 14.5.9.5 cache performance monitoring this module includes a programmable monitor 32-b it counter. the monitor can be configured to count the number of clock cycles, the number of data hit or the number of instruction hit. use the following sequence to activate the counter 1. configure the monitor counter writing the mode field of the cfg register. 2. enable the counter writing one to the menable field of the men register. 3. if required reset the counter, writing one to the swrst field of the mctrl register. 4. check the value of the monitor counter, reading event_cnt field of the sr 14.5.10 accessing the picocache memory block as a regular memory on the system bus this is only possible when the picocache is disabled. in case of an access in this memory while the picocache is active, the memory slave will re turn an error response which will result in a
273 42023e?sam?07/2013 atsam4l8/l4/l2 cortex-m4 memory fault exceptio n. when operating a chip er ase, the picocache will be cleared whether it was enabled or not.
274 42023e?sam?07/2013 atsam4l8/l4/l2 14.6 flash commands the flashcalw offers a command set to manage programming of the flash memory, locking and unlocking of regions, and full flash erasing. see section 14.10.2 for a complete list of commands. to run a command, the cmd field in the flash command register (fcmd) has to be written with the command number. as soon as the fcmd register is written, the frdy bit in the flash status register (fsr) is automatically cleared. once the current command is complete, the fsr.frdy bit is automatically set. if an interrupt has been enabled by writing a one to fcr.frdy, the interrupt request line of the flash controller is activated. all flash commands except for quick page read (qpr) and quick us er page read (qprup ) will generate an inter- rupt request upon completion if fcr.frdy is one. any hsb bus transfers attempting to read flash memory when the flashcalw is busy execut- ing a flash command will be stalled, and allo wed to continue when the flash command is complete. after a command has been written to fcmd, the programming algorithm should wait until the command has been executed before attempting to read instructions or data from the flash or writing to the page buffer, as the flash will be busy. the waiting can be pe rformed either by poll- ing the flash status register (fsr) or by waiting for the flash ready interrupt. the command written to fcmd is initiated on the first cloc k cycle where the hsb bus interface in flashcalw is idle. the user must make sure that the access pattern to the flashcalw hsb interface contains an idle cycle so that the command is allowed to start. make sure that no bus masters such as dma controllers are performing endless burst transfers from the flash. also, make sure that the cpu does not perform endless burst transfe rs from flash. this is done by letting the cpu enter power save mode afte r writing to fcmd, or by pollin g fsr for command completion. this polling will result in an acce ss pattern with idle hsb cycles. all the commands are protected by the same keyword, which has to be written in the eight high- est bits of the fcmd register. writing fcmd wi th data that does not contain the correct key and/or with an invalid command has no effect on the flash memory; however, the proge bit is set in the flash status register (fsr). this bit is automatically cleared by a read access to the fsr register. writing a command to fcmd while another command is being executed has no effect on the flash memory; however, the proge bit is set in the flash status register (fsr). this bit is automatically cleared by a read access to the fsr register. if the current command writes or erases a page in a locked region the command has no effect on the flash memory; however, the locke bit is set in the fsr register. this bit is automatically cleared by a read access to the fsr register.
275 42023e?sam?07/2013 atsam4l8/l4/l2 14.6.1 write/erase page operation flash technology requires that an erase must be done before programming. the entire flash can be erased by an erase all command. alternativ ely, pages can be individually erased by the erase page command. the user page can be written and erased usin g the mechanisms descr ibed in this chapter. after programming, the page can be locked to pr event miscellaneous write or erase sequences. locking is performed on a per-region basis, so locking a region locks all pages inside the region. data to be written is stored in an internal buffer called the page buffer. the page buffer contains w words. the page buffer wraps around within the internal memory area address space and appears to be repeated by the number of pages in it. writing of 8-bit and 16-bit data to the page buffer is not allowed and may lead to unpredictable data corruption. data must be written to the page buffer before the programming command is written to the flash command register (fcmd). the sequence is as follows: ? erase the page to be programmed. ? reset the page buffer with the clear page buffer command. ? fill the page buffer with the desired content s as described in section 14.5.8 on page 270 . ? programming starts as soon as the programming key and the programming command are written to the flash command register. the pagen field in the flash command register (fcmd) must contain the address of the page to write. pagen is automatically updated when writing to the page buffer, but can also be written to directly. the frdy bit in the flash status register (fsr) is automatically cleared when the page write operation starts. ? when programming is completed, the frdy bit in the flash status register (fsr) is set. if an interrupt was enabled by writing fcr.frdy to one, an interrupt request is generated. two errors can be detected in the fsr register after a programming sequence: ? programming error: a bad keyword and/or an invalid command have been written in the fcmd register. ? lock error: can have two different causes: ? the page to be programmed belongs to a locked region. a command must be executed to unlock the corresponding region before programming can start. ? a bus master without secure status attempted to program a page requiring secure privileges. 14.6.2 erase all operation the entire memory is erased if the erase all command (ea) is written to the flash command register (fcmd). erase all erases all bits in the flash array. the user page is not erased. all flash memory locations, the general-purpose fuse bits, and the security fuses are erased (reset to 0xff) after an erase all. the ea command also ensures that all volatile me mories, such as register file and rams, are erased before the security fuses are erased. erase all operation is allowed only if no regions ar e locked. thus, if at least one region is locked, the bit locke in fsr is set and the command is cancelled. if the locke bit in fcr is one, an interrupt request is set generated.
276 42023e?sam?07/2013 atsam4l8/l4/l2 when the command is complete, the frdy bit in th e flash status register (fsr) is set. if an interrupt has been enabled by writing fcr.frdy to one, an interrupt request is generated. two errors can be detected in the fsr register after issuing the command: ? programming error: a bad keyword and/or an invalid command have been written in the fcmd register. ? lock error: at least one lock region is protected. the erase command has been aborted and no page has been erased. a ?unlock region containing given page? (up) command must be executed to unlock any locked regions. 14.6.3 region lock bits the flash memory has p pages, and these pages are grouped into 16 lock regions, each region containing p /16 pages. each region has a dedicated lock bit preventing writing and erasing pages in the region. after production, the device may have some regions locked. these locked regions are reserved for a boot or default applic ation. locked regions can be unlocked to be erased and then programmed with another application or other data. to lock or unlock a region, the commands lock region containing page (lp) and unlock region containing page (up) are provided. writing one of these commands, together with the number of the page whose region should be locked/unlocked, performs the desired operation. one error can be detected in the fsr register after issuing the command: ? programming error: a bad keyword and/or an invalid command have been written in the fcmd register. the lock bits are implemented using the lowest 16 general-purpose fuse bits. this means that lock bits can also be set/cleared using the commands for writing/erasing general-purpose fuse bits, see section 14.7 . the general-purpose bit being in an erased (1) state means that the region is unlocked. 14.7 general-purpose fuse bits the flash memory has a number of general-purpose fuse bits that the application programmer can use freely. the fuse bits can be writ ten and erased using dedicated commands, and read through a dedicated peripheral bus address. some of the general-purpose fuse bits are reserved for special purposes, and shou ld not be used for other functions: to erase or write a general-purpose fuse bit, the commands write general-purpose fuse bit (wgpb) and erase general-purpose fuse bit (e gpb) are provided. writing one of these com- mands, together with the number of the fuse to write/erase, performs the desired operation. an entire general-purpose fuse byte can be wr itten at a time by using the program gp fuse byte (pgpfb) instruction. a pgpfb to gp fuse byte 2 is not allowed if the flash is locked by the security fuses. the pfb command is issued with a parameter in the pagen field: ? pagen[2:0] - byte to write table 14-2. general-purpose fuses with special functions general- purpose fuse number name usage 15:0 lock region lock bits.
277 42023e?sam?07/2013 atsam4l8/l4/l2 ? pagen[10:3] - fuse value to write all general-purpose fuses can be erased by the erase all general-purpose fuses (eagp) com- mand. an eagp command is not allowed if the flash is lo cked by the security fuses. two errors can be detected in the fsr register after issuing these commands: ? programming error: a bad keyword and/or an invalid command have been written in the fcmd register. ? lock error: the lock bits are implemented using the lowest 16 general-purpose fuse bits. this means that the 16 lowest general-purpose fuse bits can also be written/erased using the commands for locking/unlocking regions, see section 14.6.3 . 14.8 security fuses the security fuses allow the entire device to be locked from external jtag or other debug access for code security. the security fuses can be written by a dedicated command, set secu- rity fuses (ssb). once set, the only way to clear the security fuses is through the jtag chip erase command. once the security fuses are se t, the following flas h controller command s will be unavailable and return a lock error if attempted: ? program general-purpose fuse byte (pgpfb) of fuse byte 2 ? erase all general-purpose fuses (eagpf) one error can be detected in the fsr register after issuing the command: ? programming error: a bad keyword and/or an invalid command have been written in the fcmd register. 14.9 error correcting code error correcting code (ecc) logic is implemented to detect and correct errors that may arise in the flash array. the ecc logic is able to detect two bit errors and correct one bit error per 32-bit word in the array. an interrupt is requested upon detection of an ecc error if the ecc error interrupt enable (ecce) bit in the flash control re gister (fcr) is set is set. the eccerr field in flash status register (fsr) indicates the ecc status of the words read from the flash. upon detection of an ecc error, the ferradr register is updated with the failing address. if the ecce bit is set, ferradr is loaded only on the first occurrence of an ecc error. other- wise, it is loaded on all occurrences. ecc checking is performed on a 64-bit basis, so an ecc failure may be present in any of the two words that are output from the flash, not necessarily the word that is addressed on the bus.
278 42023e?sam?07/2013 atsam4l8/l4/l2 figure 14-5. ecc system flash block ecc calculation ftwecc 64 8 64 8 ftrecc ftrdata dcomp ecomp write data haddr ferradr ecc logic hrdata 32 eccerr eccwor eccdis acompen acompen acomperr acomperr ftecco ftrdatahi
279 42023e?sam?07/2013 atsam4l8/l4/l2 14.10 user interface note: 1. the value of the lock bits depend on their programmed state. all other bits in fsr are 0. 2. all bits in fgprhi/lo are dependent on the programmed state of the fuses they map to. any bits in these registers not mapped to a fuse read as 0. 3. the reset values for these registers are device specific. refer to the module config uration section at the end of this chapte r. table 14-3. flashcalw register memory map offset register register name access reset 0x00 flash control register fcr read/write 0x00000000 0x04 flash command register fcmd read/write 0x00000000 0x08 flash status register fsr read-only - (1) 0x0c flash parameter register fpr read-only - (3) 0x10 flash version register fvr read-only - (3) 0x14 flash general purpose fuse register hi fgpfrhi read-only - (2) 0x18 flash general purpose fuse register lo fgpfrlo read-only - (2) 0x408 picocache control register ctrl write-only 0x00000000 0x40c picocache status register sr read/write 0x00000000 0x420 picocache maintenance register 0 maint0 write-only - (3) 0x424 picocache maintenance register 1 maint1 write-only - (3) 0x428 picocache monitor configuration register mcfg read/write 0x00000000 0x42c picocache monitor enable register men read/write 0x00000000 0x430 picocache monitor control register mctrl write-only - (3) 0x434 picocache monitor status register msr read-only 0x00000000 0x4fc version register pvr read-only - (3)
280 42023e?sam?07/2013 atsam4l8/l4/l2 14.10.1 flash control register name: fcr access type: read/write offset :0x00 reset value: 0x00000000 ? reserved: must be 0. ? ? ws1opt: wait state 1 optimization 0: no action 1: optimize read accesses wh en configured with one wait state ? fws: flash wait state 0: the flash is read with 0 wait states. 1: the flash is read with 1 wait state. ? ecce: ecc error interrupt enable 0: ecc error does not generate an interrupt. 1: ecc error generates an interrupt. ? proge: programming error interrupt enable 0: programming error does not generate an interrupt request. 1: programming error generates an interrupt request. ? locke: lock error interrupt enable 0: lock error does not generate an interrupt request. 1: lock error generates an interrupt request. ? frdy: flash ready interrupt enable 0: flash ready does not generate an interrupt request. 1: flash ready generates an interrupt request. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------reserved 76543210 ws1opt fws - -ecce proge locke - frdy
281 42023e?sam?07/2013 atsam4l8/l4/l2 14.10.2 flash command register name: fcmd access type: read/write offset :0x04 reset value: 0x00000000 the fcmd can not be written if the flash is in the process of performing a flash command. doing so will cause the fcr write to be ignored , and the proge bit in fsr to be set. ? key: write protection key this field should be written with the value 0xa5 to enable the command defined by the bits of t he register. if the field is wri tten with a different value, the write is not performed and no action is started. this field always reads as 0. ?pagen: page number the pagen field is used to address a page or fuse bit for certai n operations. in order to simplify programming, the pagen field is automatically updated every time the page buffer is written to. for every page buffer write, the pagen field is updated with the page number of the address being written to. hardware automatically masks writes to the pagen field so that only bits representing valid page numbers can be writt en, all other bits in pagen are always 0. as an example, in a flash with 1024 pages (page 0 - page 1023), bits 15:10 will always be 0. 31 30 29 28 27 26 25 24 key 23 22 21 20 19 18 17 16 pagen [15:8] 15 14 13 12 11 10 9 8 pagen [7:0] 76543210 -- cmd table 14-4. semantic of pagen field in different commands command pagen description no operation not used write page the number of the page to write clear page buffer not used lock region containing given page page number whose region should be locked unlock region containing given page page number whose region should be unlocked erase all not used write general-purpose fuse bit gpfuse # erase general-purpose fuse bit gpfuse # set security fuses not used
282 42023e?sam?07/2013 atsam4l8/l4/l2 ? cmd: command this field defines the flash command. issuing any unused command will cause the programming error bit in fsr to be set, and the corresponding interrupt to be requested if the proge bit in fcr is one. program gp fuse byte writed ata[7:0], byteaddress[2:0] erase all gp fuses not used quick page read page number write user page not used erase user page not used quick page read user page not used high speed mode enable not used high speed mode disable not used table 14-5. set of commands command value mnemonic no operation 0 nop write page 1 wp erase page 2 ep clear page buffer 3 cpb lock region containing given page 4 lp unlock region containing given page 5 up erase all 6 ea write general-purpose fuse bit 7 wgpb erase general-purpose fuse bit 8 egpb set security fuses 9 ssb program gp fuse byte 10 pgpfb erase all gpfuses 11 eagpf quick page read 12 qpr write user page 13 wup erase user page 14 eup quick page read user page 15 qprup high speed mode enable 16 hsen high speed mode disable 17 hsdis reserved 20-31 table 14-4. semantic of pagen field in different commands command pagen description
283 42023e?sam?07/2013 atsam4l8/l4/l2 14.10.3 flash status register name: fsr access type: read-only offset :0x08 reset value: 0x00000000 ? lockx: lock region x lock status 0: the corresponding lock region is not locked. 1: the corresponding lock region is locked. ? eccerr: ecc error status automatically cleared when fsr is read. indicates the status of the ecc system. eccerr can only be only updated when eccerr == 0, ie for the first ecc error encountered. ? hsmode: high-speed mode 0: high-speed mode disabled. 1: high-speed mode enabled. ? qprr: quick page read result 0: the result is zero, i.e. the page is not erased. 1: the result is one, i.e. the page is erased. ? security: security fuses status 0: the security fuses value indicates a non protected state.. 1: the security fuses value indicates a protected state. ? proge: programming error status automatically cleared when fsr is read. 0: no invalid commands and no bad keywords were written in the flash command register fcmd. 1: an invalid command and/or a bad keyword was/we re written in the flash command register fcmd. ? locke: lock error status automatically cleared when fsr is read. 0: no programming of at least one locked lock region has happened since the last read of fsr. 1: programming of at least one locked lock region has happened since the last read of fsr. ? frdy: flash ready status 0: the flash controller is busy and the application must wait before running a new command. 1: the flash controller is ready to run a new command. 31 30 29 28 27 26 25 24 lock15 lock14 lock13 lock12 lock11 lock10 lock9 lock8 23 22 21 20 19 18 17 16 lock7 lock6 lock5 lock4 lock3 lock2 lock1 lock0 15 14 13 12 11 10 9 8 -------eccerr-eccerr 76543210 - hsmode qprr security proge locke - frdy
284 42023e?sam?07/2013 atsam4l8/l4/l2 14.10.4 flash parameter register name: fpr access type: read-only offset :0x0c reset value: - ? psz: page size the size of each flash page. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 ----- psz 76543210 ---- fsz table 14-6. flash page size psz page size 032 byte 164 byte 2128 byte 3256 byte 4512 byte 5 1024 byte 6 2048 byte 7 4096 byte
285 42023e?sam?07/2013 atsam4l8/l4/l2 ? fsz: flash size the size of the flash. not all device families will provide all flash sizes indicated in the table. table 14-7. flash size fszflash sizefszflash size 0 4 kbyte 8 192 kbyte 1 8 kbyte 9 256 kbyte 2 16 kbyte 10 384 kbyte 3 32 kbyte 11 512 kbyte 4 48 kbyte 12 768 kbyte 5 64 kbyte 13 1024 kbyte 6 96 kbyte 14 2048 kbyte 7 128 kbyte 15 reserved
286 42023e?sam?07/2013 atsam4l8/l4/l2 14.10.5 flash version register name: fvr access type: read-only offset :0x10 reset value: 0x00000000 ? variant: variant number reserved. no functi onality associated. ? version: version number version number of the module . no functionality associated. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 ---- variant 15 14 13 12 11 10 9 8 ---- version[11:8] 76543210 version[7:0]
287 42023e?sam?07/2013 atsam4l8/l4/l2 14.10.6 flash general purpose fuse register high name: fgpfrhi access type: read-only offset :0x14 reset value: - this register is only used in syst ems with more t han 32 gp fuses. ? gpfxx: general purpose fuse xx 0: the fuse has a written/programmed state. 1: the fuse has an erased state. 31 30 29 28 27 26 25 24 gpf63 gpf62 gpf61 gpf60 gpf59 gpf58 gpf57 gpf56 23 22 21 20 19 18 17 16 gpf55 gpf54 gpf53 gpf52 gpf51 gpf50 gpf49 gpf48 15 14 13 12 11 10 9 8 gpf47 gpf46 gpf45 gpf44 gpf43 gpf42 gpf41 gpf40 76543210 gpf39 gpf38 gpf37 gpf36 gpf35 gpf34 gpf33 gpf32
288 42023e?sam?07/2013 atsam4l8/l4/l2 14.10.7 flash general purpose fuse register low name: fgpfrlo access type: read-only offset :0x18 reset value: - ? gpfxx: general purpose fuse xx 0: the fuse has a written/programmed state. 1: the fuse has an erased state. ? ? ? 31 30 29 28 27 26 25 24 gpf31 gpf30 gpf29 gpf28 gpf27 gpf26 gpf25 gpf24 23 22 21 20 19 18 17 16 gpf23 gpf22 gpf21 gpf20 gpf19 gpf18 gpf17 gpf16 15 14 13 12 11 10 9 8 gpf15 gpf14 gpf13 gpf12 gpf11 gpf10 gpf09 gpf08 76543210 gpf07 gpf06 gpf05 gpf04 gpf03 gpf02 gpf01 gpf00
289 42023e?sam?07/2013 atsam4l8/l4/l2 14.10.8 picocache control register name: ctrl access type: write-only offset :0x408 reset value: 0x00000000 ? cen: cache enable 0: cache is disabled 1: cache is enabled 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------- 76543210 -------cen
290 42023e?sam?07/2013 atsam4l8/l4/l2 14.10.9 picocache status register name: sr access type: read-only offset :0x40c reset value: 0x00000000 ? csts: cache controller status 0: when read as 0, this field indicates that the cache controller is disabled. 1: when read as 1, this field indicate s that the cache controller is enabled. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------- 76543210 -------csts
291 42023e?sam?07/2013 atsam4l8/l4/l2 14.10.10 picocache maintenance register 0 name: maint0 access type: write-only offset :0x420 reset value: 0x00000000 ? invall: cache controller invalidate all 0: no effect. 1: when set to one, this field invalidate all cache entries. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------- 76543210 -------invall
292 42023e?sam?07/2013 atsam4l8/l4/l2 14.10.11 picocache maintenance register 1 name: maint1 access type: write-only offset :0x424 reset value: 0x00000000 ? reserved: must be null. ? index: invalidate index this field indicates the cache line that is to be invalidated 31 30 29 28 27 26 25 24 reserved ------ 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------- 76543210 index ----
293 42023e?sam?07/2013 atsam4l8/l4/l2 14.10.12 picocache monitor configuration register name: mcfg access type: read/write offset :0x428 reset value: 0x00000000 ? mode: cache controller monitor counter mode 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------- 76543210 ------ mode value name description 0 cycle_count cycle counter 1 ihit_count instruction hit counter 2 dhit_count data hit counter
294 42023e?sam?07/2013 atsam4l8/l4/l2 14.10.13 picocache monitor enable register name: men access type: write-only offset :0x42c reset value: 0x00000000 ? menable: monitor enable 0: the monitor counter is disabled 1: the monitor counter is enabled 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------- 76543210 -------menable
295 42023e?sam?07/2013 atsam4l8/l4/l2 14.10.14 picocache monitor control register name: mctrl access type: write-only offset :0x430 reset value: 0x00000000 ? swrst: monitor software reset 0: no effect 1: writing a one in this field resets the event counter register 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------- 76543210 -------swrst
296 42023e?sam?07/2013 atsam4l8/l4/l2 14.10.15 picocache monitor status register name: msr access type: read-only offset :0x434 reset value: 0x00000000 ? event_cnt: monitor event counter 31 30 29 28 27 26 25 24 event_cnt 23 22 21 20 19 18 17 16 event_cnt 15 14 13 12 11 10 9 8 event_cnt 76543210 event_cnt
297 42023e?sam?07/2013 atsam4l8/l4/l2 14.10.16 picocache version register name: pvr access type: read-only offset :0x4fc reset value: 0x00000000 ? version ?mfn 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 ----- mfn 15 14 13 12 11 10 9 8 ---- version 76543210 version
298 42023e?sam?07/2013 atsam4l8/l4/l2 14.11 fuse settings the flash contains 32 general purpose fuses. these 32 fuses can be found in the flash general purpose fuse register low (fgpfrlo). the flash general purpose fuse register high (fgpfrhi) is not used. in addition to the general purpose fuses, parts of the flash user page can have a defined meaning outs ide of the flash controller and will also be described in this section. note that when writing to the user page the values do not get loaded by the other modules on the device until a device reset occurs. the general purpose fuses are erased by a jtag chip erase.
299 42023e?sam?07/2013 atsam4l8/l4/l2 14.11.1 flash general purpose fuse register low (fgpfrlo) default fuse value: the devices are shipped wi th the fgpfrlo regist er value:0xffffffff: reserved fuses set to 1. lock fuses set to 1111111111111111. no region locked. after the jtag chip erase command, the fgpfr register value is 0xffffffff. 31 30 29 28 27 26 25 24 - ------- 23 22 21 20 19 18 17 16 - ------- 15 14 13 12 11 10 9 8 lock[15:8] 7 6543210 lock[7:0]
300 42023e?sam?07/2013 atsam4l8/l4/l2 14.11.2 first word of the user page (address 0x808000004) ? bod18hyst: 1v8 brown out detector hysteresis 0: the brown out detector hysteresis is disabled 1: the brown out detector hysteresis is enabled ? bod18action: 1v8 brown out detector action ? bod18en: 1v8 brown out detector enable 0: the brown out detector is disabled. 1: the brown out detector is enabled. ? bod18level: 1v8 brown out detector level this controls the voltage trigger level for the 1v8 brown out detector. refer to section 42. ?electrical characteristics? on page 1120 ? bod33hyst: 3v3 brown out detector hysteresis 0: the brown out detector hysteresis is disabled 1: the brown out detector hysteresis is enabled ? bod33action: 3v3 brown out detector action ? bod33en: 3v3 brown out detector enable 0: the brown out detector is disabled. 1: the brown out detector is enabled. 31 30 29 28 27 26 25 24 - ------- 23 22 21 20 19 18 17 16 - - - bod18hyst bod18action bod18en bod18level[5] 15 14 13 12 11 10 9 8 bod18level[4:0] bod33 hyst bod33action 7 6543210 bod33en bod33level wdtauto action[1:0] description 00 no action. 01 the bod generates a reset. 10 the bod generates an interrupt. 11 no action. action[1:0] description 00 no action. 01 the bod generates a reset. 10 the bod generates an interrupt. 11 no action.
301 42023e?sam?07/2013 atsam4l8/l4/l2 ? bod33level: 3v3 brown out detector level this controls the voltage trigger level for the 3v3 brown out detector. refer to section 42. ?electrical characteristics? on page 1120 . ? wdtauto: watchdog timer auto enable at startup 0: the wdt is automatical ly enabled at startup. 1: the wdt is not automatic ally enabled at startup. refer to the wdt chapter for detail about timeout settings when the wdt is automatically enabled. default user page first word value:the devices are shipped with the user page erased (all bits 1): wdtauto set to 1, wdt disabled.
302 42023e?sam?07/2013 atsam4l8/l4/l2 14.11.3 second word of the user page (address 0x80800000) default user page second word value: the devices ar e shipped with the user page erased (all bits 1). 14.12 serial number each device has a unique 120 bits serial number readable from address 0x0080020c to 0x0080021a. 14.13 module configuration the specific configuration for each flashcalw instance is listed in the following tables. the page size is 512 bytes for all configurations. 31 30 29 28 27 26 25 24 - ------- 23 22 21 20 19 18 17 16 - ------- 15 14 13 12 11 10 9 8 - ------- 7 6543210 - ------- table 14-8. module configuration feature atsam4lc4ca, atsam4lc4ba, atsam4lc4aa, atsam4ls4ca, atsam4ls4ba, atsam4ls4aa atsam4lc2ca, atsam4lc 2ba, atsam4lc2aa, atsam4ls2ca, atsam4ls2ba , atsam4ls2aa flash size 256kbytes 128kbytes number of pages 512 256 feature atsam4lc8ca, atsam4lc8ba, atsam4lc8aa, atsam4ls8ca, atsam4ls8ba, atsam4ls8aa flash size 512kbytes number of pages 1024
303 42023e?sam?07/2013 atsam4l8/l4/l2 the module bus clocks listed here are connected to the system bus clocks. refer to section 10. ?power manager (pm)? on page 108 for details table 14-9. module clock name module name clock name description flashcalw clk_flashcalw_ahb clock for the flashcalw ahb interface clk_hramc1_ahb clock for the hramc1 interface clk_flashcalw_apb clock for t he flashcalw pb interface table 14-10. register reset values register atsam4lc4ca, atsam4lc 4ba, atsam4lc4aa, atsam4ls4ca, atsam4ls4ba, atsam4ls4aa atsam4lc2ca, atsam4lc2ba, atsam4lc2aa, atsam4ls2ca, atsam4ls2ba, atsam4ls2aa fvr 0x00000110 0x00000110 fpr 0x00000409 0x00000407 register atsam4lc8ca, atsam4lc 8ba, atsam4lc8aa, atsam4ls8ca, atsam4ls8ba, atsam4ls8aa fvr 0x00000110 fpr 0x0000040b
304 42023e?sam?07/2013 atsam4l8/l4/l2 15. hsb bus matrix (hmatrixb) rev: 1.3.0.3 15.1 features ? user interface on peripheral bus ? configurable number of masters (up to 16) ? configurable number of slaves (up to 16) ? one decoder for each master ? programmable arbitration for each slave ? round-robin ? fixed priority ? programmable default master for each slave ? no default master ? last accessed default master ? fixed default master ? one cycle latency for the first access of a burst ? zero cycle latency for default master ? one special function register for each slave (not dedicated) 15.2 overview the bus matrix implements a multi-layer bus structure, that enables parallel access paths between multiple high speed bus (hsb) masters and slaves in a system, thus increasing the overall bandwidth. the bus matrix interconnects up to 16 hsb masters to up to 16 hsb slaves. the normal latency to connect a master to a slave is one cycle except for the default master of the accessed slave which is connected directly (zero cycle latency). the bus matrix provides 16 special function registers (sfr) that allow the bus matrix to support application specific features. 15.3 product dependencies in order to configure this module by accessing the user registers, other parts of the system must be configured correctly, as described below. 15.3.1 clocks the clock for the hmatrix bus interface (clk_hmatrix) is generated by the power manager. this clock is disabled at reset, and can be enaabled in the power manager. 15.4 functional description 15.4.1 special bus granting mechanism the bus matrix provides some speculative bus granting techniques in order to anticipate access requests from some masters. this mechanism reduc es latency at first access of a burst or single transfer. this bus granting mechanism sets a different default master for every slave. at the end of the current access, if no other re quest is pending, the slave remains connected to its associated default master. a slave can be as sociated with three kinds of default masters: no default master, last access master, and fixed default master.
305 42023e?sam?07/2013 atsam4l8/l4/l2 to change from one kind of default master to another, the bus matrix user interface provides the slave configuration registers, one for each slave, that set a default master for each slave. the slave configuration register contains two fields: defmstr_type and fixed_defmstr. the 2-bit defmstr_type field selects the default mast er type (no default, last access master, fixed default master), whereas the 4-bit fixed_defmstr field selects a fixed default master pro- vided that defmstr_type is set to fixed default master. refer to the bus matrix user interface description. 15.4.1.1 no default master at the end of the current access, if no other request is pending, the slave is disconnected from all masters. no default ma ster suits low-power mode. 15.4.1.2 last access master at the end of the current access, if no other re quest is pending, the slave remains connected to the last master that performed an access request. 15.4.1.3 fixed default master at the end of the current access, if no other r equest is pending, the slave connects to its fixed default master. unlike last access master, the fixed master does not change unless the user modifies it by a software action (field fixed_defmstr of the related scfg). 15.4.2 arbitration the bus matrix provides an arbitration mechanism that reduces latency when conflict cases occur, i.e. when two or more masters try to access the same slave at the same time. one arbiter per hsb slave is provided, thus ar bitrating each slave differently. the bus matrix provides the user with the possibility of choosing between 2 arbitration types for each slave: 1. round-robin arbitration (default) 2. fixed priority arbitration this is selected by the arbt field in the slave configuration registers (scfg). each algorithm may be complemented by selecting a default master configuration for each slave. when a re-arbitration must be done, specific conditions apply. this is described in ?arbitration rules? . 15.4.2.1 arbitration rules each arbiter has the ability to arbitrate between two or more different master requests. in order to avoid burst breaking and also to provide the maximum throughput for slave interfaces, arbitra- tion may only take place during the following cycles: 1. idle cycles: when a slave is not connected to any master or is connected to a master which is not currently accessing it. 2. single cycles: when a slave is currently doing a single access. 3. end of burst cycles: when the current cycle is the last cycle of a burst transfer. for defined length burst, predicted end of burst matches the size of the transfer but is man- aged differently for undefined length burst. this is described below. 4. slot cycle limit: when the slot cycle counte r has reached the limit value indicating that the current master access is too long and must be broken. this is described below.
306 42023e?sam?07/2013 atsam4l8/l4/l2 ? undefined length burst arbitration in order to avoid long slave handling during unde fined length bursts (incr), the bus matrix pro- vides specific logic in order to re-arbitrate before the end of the incr transfer. a predicted end of burst is used as a defined length burst transfer and can be selected among the following five possibilities: 1. infinite: no predicted end of burst is gen erated and therefore i ncr burst transfer will never be broken. 2. one beat bursts: predicted end of burst is generated at each single transfer inside the incp transfer. 3. four beat bursts: predicted end of burst is generated at the end of each four beat boundary inside incr transfer. 4. eight beat bursts: predicted end of burst is generated at the end of each eight beat boundary inside incr transfer. 5. sixteen beat bursts: predicted end of burst is generated at the end of each sixteen beat boundary inside incr transfer. this selection can be done through the ulbt field in the master configuration registers (mcfg). ? slot cycle limit arbitration the bus matrix contains specific logic to break long accesses, such as very long bursts on a very slow slave (e.g., an external low speed memory). at the beginning of the burst access, a counter is loaded with the value previously written in the slot_cycle field of the related slave configuration register (scfg) and decreased at each clock cycle. when the counter reaches zero, the arbiter has the ability to re-arbitrate at the end of the current byte, halfword, or word transfer. 15.4.2.2 round-robin arbitration this algorithm allows the bus matrix arbiters to dispatch the requests from different masters to the same slave in a round-robin manner. if two or more master requests arise at the same time, the master with the lowest number is first serviced, then the others are serviced in a round-robin manner. there are three round-robin algorithms implemented: 1. round-robin arbitration without default master 2. round-robin arbitration with last default master 3. round-robin arbitration with fixed default master ? round-robin arbitration without default master this is the main algorithm used by bus matrix arbiters. it allows the bus matrix to dispatch requests from different masters to the same slave in a pure round-robin manner. at the end of the current access, if no other request is pending, the slave is disconnected from all masters. this configuration incurs one latency cycle for the first access of a burst. arbitration without default master can be used for masters that perform significant bursts. ? round-robin arbitration with last default master this is a biased round-robin algorithm used by bus matrix arbiters. it allows the bus matrix to remove the one latency cycle for the last master that accessed the slave. at the end of the cur-
307 42023e?sam?07/2013 atsam4l8/l4/l2 rent transfer, if no other master request is pending, the slave remains connected to the last master that performed the acce ss. other non privileged masters still get one latency cycle if they want to access the same slave. this technique can be used for masters that mainly perform sin- gle accesses. ? round-robin arbitration with fixed default master this is another biased round-robin algorithm. it a llows the bus matrix arbiters to remove the one latency cycle for the fixed default master per slav e. at the end of the current access, the slave remains connected to its fixed default master. every request attempted by this fixed default mas- ter will not cause any latency whereas other non privileged masters w ill still get one latency cycle. this technique can be used for masters that mainly perform single accesses. 15.4.2.3 fixed priority arbitration this algorithm allows the bus matrix arbiters to dispatch the requests from different masters to the same slave by using the fixed priority defined by the user. if two or more master requests are active at the same time, the master with the highest priority number is serviced first. if two or more master requests with the same priority are active at the same time, the master with the highest number is serviced first. for each slave, the priority of each master may be defined through the priority registers for slaves (pras and prbs). 15.4.3 slave and master assignation the index number assigned to bus matrix slaves and masters are described in the module con- figuration section at the end of this chapter.
308 42023e?sam?07/2013 atsam4l8/l4/l2 15.5 user interface table 15-1. hmatrix register memory map offset register register name access reset 0x0000 master configuration register 0 mcfg0 read/write 0x00000002 0x0004 master configuration register 1 mcfg1 read/write 0x00000002 0x0008 master configuration register 2 mcfg2 read/write 0x00000002 0x000c master configuration register 3 mcfg3 read/write 0x00000002 0x0010 master configuration register 4 mcfg4 read/write 0x00000002 0x0014 master configuration register 5 mcfg5 read/write 0x00000002 0x0018 master configuration register 6 mcfg6 read/write 0x00000002 0x001c master configuration register 7 mcfg7 read/write 0x00000002 0x0020 master configuration register 8 mcfg8 read/write 0x00000002 0x0024 master configuration register 9 mcfg9 read/write 0x00000002 0x0028 master configuration register 10 mcfg10 read/write 0x00000002 0x002c master configuration regi ster 11 mcfg11 read/write 0x00000002 0x0030 master configuration register 12 mcfg12 read/write 0x00000002 0x0034 master configuration register 13 mcfg13 read/write 0x00000002 0x0038 master configuration register 14 mcfg14 read/write 0x00000002 0x003c master configuration regi ster 15 mcfg15 read/write 0x00000002 0x0040 slave configuration register 0 scfg0 read/write 0x00000010 0x0044 slave configuration register 1 scfg1 read/write 0x00000010 0x0048 slave configuration register 2 scfg2 read/write 0x00000010 0x004c slave configuration register 3 scfg3 read/write 0x00000010 0x0050 slave configuration register 4 scfg4 read/write 0x00000010 0x0054 slave configuration register 5 scfg5 read/write 0x00000010 0x0058 slave configuration register 6 scfg6 read/write 0x00000010 0x005c slave configuration register 7 scfg7 read/write 0x00000010 0x0060 slave configuration register 8 scfg8 read/write 0x00000010 0x0064 slave configuration register 9 scfg9 read/write 0x00000010 0x0068 slave configuration register 10 scfg10 read/write 0x00000010 0x006c slave configuration register 11 scfg11 read/write 0x00000010 0x0070 slave configuration register 12 scfg12 read/write 0x00000010 0x0074 slave configuration register 13 scfg13 read/write 0x00000010 0x0078 slave configuration register 14 scfg14 read/write 0x00000010 0x007c slave configuration register 15 scfg15 read/write 0x00000010 0x0080 priority register a for slave 0 pras0 read/write 0x00000000 0x0084 priority register b for slave 0 prbs0 read/write 0x00000000 0x0088 priority register a for slave 1 pras1 read/write 0x00000000
309 42023e?sam?07/2013 atsam4l8/l4/l2 0x008c priority register b for slave 1 prbs1 read/write 0x00000000 0x0090 priority register a for slave 2 pras2 read/write 0x00000000 0x0094 priority register b for slave 2 prbs2 read/write 0x00000000 0x0098 priority register a for slave 3 pras3 read/write 0x00000000 0x009c priority register b for slave 3 prbs3 read/write 0x00000000 0x00a0 priority register a for slave 4 pras4 read/write 0x00000000 0x00a4 priority register b for slave 4 prbs4 read/write 0x00000000 0x00a8 priority register a for slave 5 pras5 read/write 0x00000000 0x00ac priority register b for slave 5 prbs5 read/write 0x00000000 0x00b0 priority register a for slave 6 pras6 read/write 0x00000000 0x00b4 priority register b for slave 6 prbs6 read/write 0x00000000 0x00b8 priority register a for slave 7 pras7 read/write 0x00000000 0x00bc priority register b for slave 7 prbs7 read/write 0x00000000 0x00c0 priority register a for slave 8 pras8 read/write 0x00000000 0x00c4 priority register b for slave 8 prbs8 read/write 0x00000000 0x00c8 priority register a for slave 9 pras9 read/write 0x00000000 0x00cc priority register b for slave 9 prbs9 read/write 0x00000000 0x00d0 priority register a for slave 10 pras10 read/write 0x00000000 0x00d4 priority register b for slave 10 prbs10 read/write 0x00000000 0x00d8 priority register a for slave 11 pras11 read/write 0x00000000 0x00dc priority register b for slave 11 prbs11 read/write 0x00000000 0x00e0 priority register a for slave 12 pras12 read/write 0x00000000 0x00e4 priority register b for slave 12 prbs12 read/write 0x00000000 0x00e8 priority register a for slave 13 pras13 read/write 0x00000000 0x00ec priority register b for slave 13 prbs13 read/write 0x00000000 0x00f0 priority register a for slave 14 pras14 read/write 0x00000000 0x00f4 priority register b for slave 14 prbs14 read/write 0x00000000 0x00f8 priority register a for slave 15 pras15 read/write 0x00000000 0x00fc priority register b for slave 15 prbs15 read/write 0x00000000 0x0110 special function register 0 sfr0 read/write ? 0x0114 special function register 1 sfr1 read/write ? 0x0118 special function register 2 sfr2 read/write ? 0x011c special function register 3 sfr3 read/write ? 0x0120 special function register 4 sfr4 read/write ? 0x0124 special function register 5 sfr5 read/write ? 0x0128 special function register 6 sfr6 read/write ? table 15-1. hmatrix register memory map (continued) offset register register name access reset
310 42023e?sam?07/2013 atsam4l8/l4/l2 0x012c special function register 7 sfr7 read/write ? 0x0130 special function register 8 sfr8 read/write ? 0x0134 special function register 9 sfr9 read/write ? 0x0138 special function register 10 sfr10 read/write ? 0x013c special function register 11 sfr11 read/write ? 0x0140 special function register 12 sfr12 read/write ? 0x0144 special function register 13 sfr13 read/write ? 0x0148 special function register 14 sfr14 read/write ? 0x014c special function register 15 sfr15 read/write ? table 15-1. hmatrix register memory map (continued) offset register register name access reset
311 42023e?sam?07/2013 atsam4l8/l4/l2 15.5.1 master configuration registers name: mcfg0...mcfg15 access type: read/write offset: 0x00 - 0x3c reset value: 0x00000002 ? ulbt: undefined length burst type 31 30 29 28 27 26 25 24 ???????? 23 22 21 20 19 18 17 16 ???????? 15 14 13 12 11 10 9 8 ???????? 76543210 ????? ulbt table 15-2. undefined length burst type ulbt undefined length burst type description 000 inifinite length burst no predicted end of burst is generated and theref ore incr bursts coming from this master cannot be broken. 001 single-access the undefined length burst is treated as a succession of single accesses, allowing re- arbitration at each beat of the incr burst. 010 4 beat burst the undefined length bu rst is split into a four-beat burst, allowing re-arbitration at each four-beat burst end. 011 8 beat burst the undefined length burst is split into an eight-beat burst, allowing re-arbitration at each eight-beat burst end. 100 16 beat burst the undefined length burst is split in to a sixteen-beat burst, allowing re-arbitration at each sixteen-beat burst end.
312 42023e?sam?07/2013 atsam4l8/l4/l2 15.5.2 slave configuration registers name: scfg0...scfg15 access type: read/write offset: 0x40 - 0x7c reset value: 0x00000010 ? arbt: arbitration type 0: round-robin arbitration 1: fixed priority arbitration ? fixed_defmstr: fixed default master this is the number of the default master for this slave. only used if defmstr_type is 2. sp ecifying the number of a master which is not connected to the selected slave is equivalent to sett ing defmstr_type to 0. ? defmstr_type: default master type 0: no default master at the end of the current slave access, if no other master r equest is pending, the slave is disconnected from all masters. this results in a one cycle latenc y for the first access of a burst transfer or for a single access. 1: last default master at the end of the current slave access, if no other master req uest is pending, the slave stays connected to the last master hav ing accessed it. this results in not having one cycle latency when the last master tries to access the slave again. 2: fixed default master at the end of the current slave access, if no other master request is pending, the slav e connects to the fixed master the numbe r that has been written in the fixed_defmstr field. this results in not having one cycle latency when the fixed master tries to access the slave again. ? slot_cycle: maximum number of allowed cycles for a burst when the slot_cycle limit is reached for a burst, it may be broken by another master trying to access this slave. this limit has been placed to avoid locking a very slow slave when very long bursts are used. this limit must not be very small. unreas onably small values break every burst and the bus matrix arbitrates without performing any data transfer. 16 cycles is a reasonable value for slot_cycle. 31 30 29 28 27 26 25 24 ???????arbt 23 22 21 20 19 18 17 16 ? ? fixed_defmstr defmstr_type 15 14 13 12 11 10 9 8 ???????? 76543210 slot_cycle
313 42023e?sam?07/2013 atsam4l8/l4/l2 15.5.3 bus matrix priority registers a for slaves register name: pras0...pras15 access type: read/write offset: - reset value: 0x00000000 ? mxpr: master x priority fixed priority of master x for accessing the selected slave. the higher the number, the higher the priority. 31 30 29 28 27 26 25 24 - - m7pr - - m6pr 23 22 21 20 19 18 17 16 - - m5pr - - m4pr 15 14 13 12 11 10 9 8 - - m3pr - - m2pr 76543210 - - m1pr - - m0pr
314 42023e?sam?07/2013 atsam4l8/l4/l2 15.5.4 priority registers b for slaves name: prbs0...prbs15 access type: read/write offset: - reset value: 0x00000000 ? mxpr: master x priority fixed priority of master x for accessing the selected slave. the higher the number, the higher the priority. 31 30 29 28 27 26 25 24 - - m15pr - - m14pr 23 22 21 20 19 18 17 16 - - m13pr - - m12pr 15 14 13 12 11 10 9 8 - - m11pr - - m10pr 76543210 - - m9pr - - m8pr
315 42023e?sam?07/2013 atsam4l8/l4/l2 15.5.5 special function registers name: sfr0...sfr15 access type: read/write offset: 0x110 - 0x14c reset value: - ? sfr: special function register fields those registers are not a hmatrix spec ific register. the field of those will be defined where they are used. 31 30 29 28 27 26 25 24 sfr 23 22 21 20 19 18 17 16 sfr 15 14 13 12 11 10 9 8 sfr 76543210 sfr
316 42023e?sam?07/2013 atsam4l8/l4/l2 15.6 module configuration the specific configuration for each hmatrix instance is listed in the following tables.the mod- ule bus clocks listed here are connected to the system bus clocks. refer to section 10. ?power manager (pm)? on page 108 for details. 15.6.1 bus matrix connections the bus matrix has the several masters and slaves. each master has its own bus and its own decoder, thus allowing a different memory mapping per master. the master number in the table below can be used to index the hmatrix cont rol registers. for example, hmatrix mcfg0 register is associated with the cpu idcode master interface. each slave has its own arbiter, thus allowing a different arbitration per slave. the slave number in the table below can be used to index the hmatrix control registers. for example, scfg5 is associated with the internal sram slave interface. accesses to unused areas returns an error result to the master requesting such an access. table 15-3. hmatrix clocks clock name description clk_hmatrix clock for the hmatrix bus interface table 15-4. high speed bus masters master 0 cpu idcode master 1 cpu sys master 2 smap master 3 pdca master 4 usbc master 5 crccu table 15-5. high speed bus slaves slave 0 internal flash slave 1 ahb-apb bridge a slave 2 ahb-apb bridge b slave 3 ahb-apb bridge c slave 4 ahb-apb bridge d slave 5 internal sram slave 6 internal sram for cache slave 7 aesa
317 42023e?sam?07/2013 atsam4l8/l4/l2 figure 15-1. hmatrix master / slave connections cpu idcode 0 cpu sys 1 smap 2 pdca 3 hmatrix masters usbc 4 crccu 5 hmatrix slaves internal flash 0 ahb-apb bridge 0 1 2 3 4 internal sram 5 internal sram for cache 6 aesa 7 ahb-apb bridge 1 ahb-apb bridge 2 ahb-apb bridge 3
318 42023e?sam?07/2013 atsam4l8/l4/l2 16. peripheral dma controller (pdca) rev: 1.2.4.1 16.1 features ? multiple channels ? generates transfers between memories and peripherals such as usart and spi ? two address pointers/counters per ch annel allowing double buffering ? optional synchronizing of data transfers with extenal peripheral events ? ring buffer functionality 16.2 overview the peripheral dma controller (pdca) transfers data between on-chip peripheral modules such as usart, spi and memories (those memories ma y be on- and off-chip memories). using the pdca avoids cpu intervention for data transfers, improving the performance of the microcon- troller. the pdca can transfer data from memory to a peripheral or from a peripheral to memory. the pdca consists of multiple dma channels. each channel has: ? a peripheral select register ? a 32-bit memory pointer ? a 16-bit transfer counter ? a 32-bit memory pointer reload value ? a 16-bit transfer counter reload value the pdca communicates with the peripheral modules over a set of handshake interfaces. the peripheral signals the pdca when it is ready to receive or transmit data. the pdca acknowl- edges the request when the transmission has started. when a transmit buffer is empty or a receive buffer is full, an optional interrupt request can be generated.
319 42023e?sam?07/2013 atsam4l8/l4/l2 16.3 block diagram figure 16-1. pdca block diagram 16.4 product dependencies in order to use this module, other parts of the system must be configured correctly, as described below. 16.4.1 power management if the cpu enters a sleep mode that disables the pdca clocks, the pdca will stop functioning and resume operation after the system wakes up from sleep mode. 16.4.2 clocks the pdca has two bus clocks connected: one high speed bus clock (clk_pdca_hsb) and one peripheral bus clock (clk_pdca_pb). thes e clocks are generated by the power man- ager. the status of both clocks at reset can be known in the power manager section. it is recommended to disable the pdca before disabling the clocks, to avoid freezing the pdca in an undefined state. 16.4.3 interrupts the pdca interrupt request lines are connected to the nvic. using the pdca interrupts requires the nvic to be programmed first. hsb to pb bridge peripheral dma controller (pdca) peripheral 0 high speed bus matrix handshake interfaces peripheral bus irq hsb hsb interrupt controller peripheral 1 peripheral 2 peripheral (n-1) ... memory hsb
320 42023e?sam?07/2013 atsam4l8/l4/l2 16.4.4 peripheral events the pdca peripheral events are connected via the peripheral event system. refer to section 31. ?peripheral ev ent controller (pevc )? on page 844 for details. 16.5 functional description 16.5.1 basic operation the pdca consists of multiple independent pdca channels, each capable of handling dma requests in parallel. each pdca channels contains a set of configuration registers which must be configured to start a dma transfer. in this section the steps necessary to configure one pdca channel is outlined. the peripheral to transfer data to or from must be configured correctly in the peripheral select register (psr). this is performed by writing the peripheral identity (pid) value for the corre- sponding peripheral to the pid field in the ps r register. the pid also encodes the transfer direction, i.e. memory to peripheral or peripheral to memory. see section 16.5.6 . the transfer size must be written to the transfer size field in the mode register (mr.size). the size must match the data size produced or consumed by the selected peripheral. see section 16.5.7 . the memory address to transfer to or from, depending on the psr, must be written to the mem- ory address register (mar). for each transfer the memory address is increased by either a one, two or four, depending on the size set in mr. see section 16.5.2 . the number of data items to transfer is written to the tcr register. if the pdca channel is enabled, a transfer will start imm ediately after writing a non-zero value to tc r or the reload ver- sion of tcr, tcrr. after each transfer the tcr value is decreased by one. both mar and tcr can be read while the pdca channel is active to monitor the dma progress. see section 16.5.3 . the channel must be enabled for a transfer to start. a channel is enable by writing a one to the en bit in the control register (cr). 16.5.2 memory pointer each channel has a 32-bit memory address regi ster (mar). this register holds the memory address for the next transfer to be performed. the register is automatically updated after each transfer. the address will be increa sed by either one, two or four depending on the size of the dma transfer (byte, halfword or word). the mar can be read at any time during transfer. 16.5.3 transfer counter each channel has a 16-bit transfer counter register (tcr). this register must be written with the number of transfers to be performed. the tcr register should contain the number of data items to be transferred independently of the transfer size. the tcr can be read at any time dur- ing transfer to see the number of remaining transfers. 16.5.4 reload registers both the mar and the tcr have a reload regist er, respectively memory address reload regis- ter (marr) and transfer counter reload register (tcrr). these registers provide the possibility for the pdca to work on two memory buffer s for each channel. when one buffer has completed, mar and tcr will be re loaded with the values in marr and tcrr. the reload logic is always enabled and will trigger if the tcr reaches zero while tcrr holds a non-zero value. after reload, the marr and tcrr registers are cleared.
321 42023e?sam?07/2013 atsam4l8/l4/l2 if tcr is zero when writing to tcrr, the tcr and mar are automatically updated with the value written in tcrr and marr. 16.5.5 ring buffer when ring buffer mode is enabled the tcrr and marr regi sters will not be cleared when tcr and mar registers reload. th is allows the pdca to read or write to the same memory region over and over again until the transfer is actively stopped by the user. ring buffer mode is enabled by writing a one to the ring buffer bit in the mode register (mr.ring). 16.5.6 peripheral selection the peripheral select register (psr) decides which peripheral should be connected to the pdca channel. a peripheral is selected by writing the corresponding peripheral identity (pid) to the pid field in the psr register. writing the pid will both select the direction of the transfer (memory to peripheral or peripheral to memory ), which handshake interface to use, and the address of the peripheral holding register. refer to the peripheral identity (pid) table in the mod- ule configuration section for the peripheral pid values. 16.5.7 transfer size the transfer size can be set individually for each channel to be either byte, halfword or word (8- bit, 16-bit or 32-bit respectively). transfer size is set by writing the desired value to the transfer size field in the mode register (mr.size). when the pdca moves data between peripherals and memory, data is automatically sized and aligned. when memory is accessed, the size specified in mr.size and system alignment is used. when a peripheral register is accessed t he data to be transferred is converted to a word where bit n in the data corresponds to bit n in the peripheral register. if the transfer size is byte or halfword, bits greater than 8 and16 respectively are set to zero. refer to the module configuration section for information regarding what peripheral registers are used for the different peripherals and then to the peripheral specific chapter for information about the size option available for the different registers. 16.5.8 enabling and disabling each dma channel is enabled by writing a one to the transfer enable bit in the control register (cr.ten) and disabled by writing a one to the transfer disable bit (cr.tdis). the current sta- tus can be read from the status register (sr). while the pdca channel is enabled all dma re quest will be handled as long the tcr and tcrr is not zero. 16.5.9 interrupts interrupts can be enabled by writing a one to the corresponding bit in the interrupt enable regis- ter (ier) and disabled by writing a one to the corresponding bit in the interrupt disable register (idr). the interrupt mask register (imr) can be read to see whether an interrupt is enabled or not. the current status of an interrupt source can be read through the interrupt status register (isr). the pdca has three interrupt sources: ? reload counter zero - the tcrr register is zero. ? transfer finished - both the tcr and tcrr registers are zero. ? transfer error - an error has occurred in accessing memory.
322 42023e?sam?07/2013 atsam4l8/l4/l2 16.5.10 priority if more than one pdca channel is requesting transfer at a given time, the pdca channels are prioritized by their channel number. channels wi th lower numbers have priority over channels with higher numbers, giving channel zero the highest priority. 16.5.11 error handling if the memory address register (mar) is set to point to an invalid location in memory, an error will occur when the pdca tries to perform a transfer. when an error occurs, the transfer error bit in the interrup t status register (isr.terr) will be se t and the dma channel that caused the error will be stopped. in order to restart the channel, the user must program the memory address register to a valid address and then write a one to the error clear bit in the control register (cr.eclr). if the transfer error interrupt is enabled , an interrupt request will be gener- ated when a transfer error occurs. 16.5.12 peripheral event trigger peripheral events can be used to trigger pdca channel transfers. peripheral event synchroniza- tions are enabled by writing a one to the event trigger bit in the mode register (mr.etrig). when set, all dma requests will be blocked until a peripheral event is re ceived. for each periph- eral event received, only one data item is transferred. if no dma requests are pending when a peripheral event is received, the pdca will st art a transfer as soon as a peripheral event is detected. if multiple events are received while the pdca channel is busy transferring data, an overflow condition will be signaled in the peripheral event system. refer to section 31. ?periph- eral event controller (pevc)? on page 844 for more information.
323 42023e?sam?07/2013 atsam4l8/l4/l2 16.6 user interface 16.6.1 memory map overview the channels are mapped as shown in table 16-1 . each channel has a set of configuration reg- isters, shown in table 16-2 , where n is the channel number. 16.6.2 channel memory map note: 1. the reset values are device specific. refer to the module configuration section at the end of this chapter. 16.6.3 version register memory map note: 1. the reset values are device specific. refer to the module configuration section at the end of this chapter. table 16-1. pdca register memory map address range contents 0x000 - 0x03f dma channel 0 configuration registers 0x040 - 0x07f dma channel 1 configuration registers ... ... (0x000 - 0x03f)+m*0x040 dma channel m configuration registers 0x834 version register table 16-2. pdca channel configuration registers offset register register name access reset 0x000 + n*0x040 memory address register mar read/write 0x00000000 0x004 + n*0x040 peripheral select register psr read/write - (1) 0x008 + n*0x040 transfer counter register tcr read/write 0x00000000 0x00c + n*0x040 memory address reload register marr read/write 0x00000000 0x010 + n*0x040 transfer counter reload register tcrr read/write 0x00000000 0x014 + n*0x040 control register cr write-only 0x00000000 0x018 + n*0x040 mode register mr read/write 0x00000000 0x01c + n*0x040 status register sr read-only 0x00000000 0x020 + n*0x040 interrupt enable register ier write-only 0x00000000 0x024 + n*0x040 interrupt disable register idr write-only 0x00000000 0x028 + n*0x040 interrupt mask register imr read-only 0x00000000 0x02c + n*0x040 interrupt status register isr read-only 0x00000000 table 16-3. pdca version register memory map offset register register name access reset 0x834 version register version read-only - (1)
324 42023e?sam?07/2013 atsam4l8/l4/l2 16.6.4 memory address register name: mar access type: read/write offset: 0x000 + n*0x040 reset value: 0x00000000 ? maddr: memory address address of memory buffer. maddr should be programmed to poin t to the start of the memory buffer when configuring the pdca. during transfer, maddr will point to the next memory location to be read/written. 31 30 29 28 27 26 25 24 maddr[31:24] 23 22 21 20 19 18 17 16 maddr[23:16] 15 14 13 12 11 10 9 8 maddr[15:8] 76543210 maddr[7:0]
325 42023e?sam?07/2013 atsam4l8/l4/l2 16.6.5 peripheral select register name: psr access type: read/write offset: 0x004 + n*0x040 reset value: - ? pid: peripheral identifier the peripheral identifier selects which peripheral should be con nected to the dma channel. writ ing a pid will select both which handshake interface to use, the direction of the transfer and also the address of the receive/transfer holding register for the peripheral. see the module configuration section of pdca for details. the width of the pid field is device specific and dependent on the number of peripheral modules in the device. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------- 76543210 pid
326 42023e?sam?07/2013 atsam4l8/l4/l2 16.6.6 transfer counter register name: tcr access type: read/write offset: 0x008 + n*0x040 reset value: 0x00000000 ? tcv: transfer counter value number of data items to be transferred by the pdca. tcv must be programmed with the total number of transfers to be made. during transfer, tcv contains the number of remaining transfers to be done. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 tcv[15:8] 76543210 tcv[7:0]
327 42023e?sam?07/2013 atsam4l8/l4/l2 16.6.7 memory address reload register name: marr access type: read/write offset: 0x00c + n*0x040 reset value: 0x00000000 ? marv: memory address reload value reload value for the mar register. this value will be loaded in to mar when tcr reaches zero if the tcrr register has a non- zero value. 31 30 29 28 27 26 25 24 marv[31:24] 23 22 21 20 19 18 17 16 marv[23:16] 15 14 13 12 11 10 9 8 marv[15:8] 76543210 marv[7:0]
328 42023e?sam?07/2013 atsam4l8/l4/l2 16.6.8 transfer counter reload register name: tcrr access type: read/write offset: 0x010 + n*0x040 reset value: 0x00000000 ? tcrv: transfer counter reload value reload value for the tcr register. when tcr reaches zero, it will be reloaded with tcrv if tcrv has a positive value. if tcrv is zero, no more transfers will be performed for the chann el. when tcr is reloaded, the tcrr register is cleared. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 tcrv[15:8] 76543210 tcrv[7:0]
329 42023e?sam?07/2013 atsam4l8/l4/l2 16.6.9 control register name: cr access type: write-only offset: 0x014 + n*0x040 reset value: 0x00000000 ? eclr: transfer error clear writing a zero to this bit has no effect. writing a one to this bit will clear the transfer error bit in the status register (sr.terr). clearing the sr.terr bit will all ow the channel to transmit data. the memory address must first be set to point to a valid location. ? tdis: transfer disable writing a zero to this bit has no effect. writing a one to this bit will disable transfer for the dma channel. ? ten: transfer enable writing a zero to this bit has no effect. writing a one to this bit will enable transfer for the dma channel. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------eclr 76543210 ------tdisten
330 42023e?sam?07/2013 atsam4l8/l4/l2 16.6.10 mode register name: mr access type: read/write offset: 0x018 + n*0x040 reset value: 0x00000000 ? ring: ring buffer 0:the ring buffer functionality is disabled. 1:the ring buffer functionality is enabled. when enabled, the reload registers, marr and tcrr will not be cleared after reload. ? etrig: event trigger 0:start transfer when the peripheral selected in periph eral select register (psr) requests a transfer. 1:start transfer only when or after a peripheral event is received. ? size: size of transfer 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------- 76543210 - - - - ring etrig size table 16-4. size of transfer size size of transfer 0 byte 1 halfword 2word 3 reserved
331 42023e?sam?07/2013 atsam4l8/l4/l2 16.6.11 status register name: sr access type: read-only offset: 0x01c + n*0x040 reset value: 0x00000000 ? ten: transfer enabled this bit is cleared when the tdis bit in cr is written to one. this bit is set when the ten bit in cr is written to one. 0: transfer is disabled for the dma channel. 1: transfer is enabled for the dma channel. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------- 76543210 -------ten
332 42023e?sam?07/2013 atsam4l8/l4/l2 16.6.12 interrupt enable register name: ier access type: write-only offset: 0x020 + n*0x040 reset value: 0x00000000 writing a zero to a bit in this register has no effect. writing a one to a bit in this register will set the corresponding bit in imr. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------- 76543210 - - - - - terr trc rcz
333 42023e?sam?07/2013 atsam4l8/l4/l2 16.6.13 interrupt disable register name: idr access type: write-only offset: 0x024 + n*0x040 reset value: 0x00000000 writing a zero to a bit in this register has no effect. writing a one to a bit in this register will clear the corresponding bit in imr. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------- 76543210 - - - - - terr trc rcz
334 42023e?sam?07/2013 atsam4l8/l4/l2 16.6.14 interrupt mask register name: imr access type: read-only offset: 0x028 + n*0x040 reset value: 0x00000000 0: the corresponding interrupt is disabled. 1: the corresponding interrupt is enabled. a bit in this register is cleared when the corresponding bit in idr is written to one. a bit in this register is set when the corresponding bit in ier is written to one. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------- 76543210 - - - - - terr trc rcz
335 42023e?sam?07/2013 atsam4l8/l4/l2 16.6.15 interrupt status register name: isr access type: read-only offset: 0x02c + n*0x040 reset value: 0x00000000 ? terr: transfer error this bit is cleared when no transfer errors ha ve occurred since the last write to cr.eclr. this bit is set when one or more transfer errors has occurred since reset or the last write to cr.eclr. ? trc: transfer complete this bit is cleared when the tcr and/or the tcrr holds a non-zero value. this bit is set when both the tcr and the tcrr are zero. ? rcz: reload counter zero this bit is cleared when the tcrr holds a non-zero value. this bit is set when tcrr is zero. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------- 76543210 - - - - - terr trc rcz
336 42023e?sam?07/2013 atsam4l8/l4/l2 16.6.16 pdca version register name: version access type: read-only offset: 0x834 reset value: - ? variant: variant number reserved. no functionality associated. ? version: version number version number of the module. no functionality associated. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 ---- variant 15 14 13 12 11 10 9 8 - - - - version[11:8] 76543210 version[7:0]
337 42023e?sam?07/2013 atsam4l8/l4/l2 16.7 module configuration the specific configuration for each pdca instance is listed in the following tables.the module bus clocks listed here are connected to the system bus clocks. refer to section 10. ?power man- ager (pm)? on page 108 for details. table 16-5. pdca configuration feature pdca number of channels 16 number of performance monitors 0 table 16-6. module clock name module name clock name description pdca clk_pdca_hsb clock for the pdca hsb interface clk_pdca_pb clock for the pdca pb interface table 16-7. register reset values register reset value psr ch 0 0 psr ch 1 1 psr ch 2 2 psr ch 3 3 psr ch 4 4 psr ch 5 5 psr ch 6 6 psr ch 7 7 psr ch 8 8 psr ch 9 9 psr ch 10 10 psr ch 11 11 psr ch 12 12 psr ch 13 13 psr ch 14 14 psr ch 15 15 version 124
338 42023e?sam?07/2013 atsam4l8/l4/l2 the table below defines the valid peripheral ident ifiers (pids). the dire ction is specified as observed from the memory, so rx means transfers from peripheral to memory and tx means from memory to peripheral. table 16-8. peripheral identity values pid direction peripheral in stance peripheral register 0 rx usart0 rhr 1 rx usart1 rhr 2 rx usart2 rhr 3 rx usart3 rhr 4 rx spi rdr 5 rx twim0 rhr 6 rx twim1 rhr 7 rx twim2 rhr 8 rx twim3 rhr 9 rx twis0 rhr 10 rx twis1 rhr 11 rx adcife lcv 12 rx catb multiple 13 - - - 14 rx iisc rhr (ch0) 15 rx iisc rhr (ch1) 16 rx parc rhr 17 rx aesa odata 18 tx usart0 thr 19 tx usart1 thr 20 tx usart2 thr 21 tx usart3 thr 22 tx spi tdr 23 tx twim0 thr 24 tx twim1 thr 25 tx twim2 thr 26 tx twim3 thr 27 tx twis0 thr 28 tx twis1 thr 29 tx adcife cdma 30 tx catb multiple 31 tx abdacb sdr0 32 tx abdacb sdr1
339 42023e?sam?07/2013 atsam4l8/l4/l2 33 tx iisc thr (ch0) 34 tx iisc thr (ch1) 35 tx dacc cdr 36 tx aesa idata 37 tx lcdca acmdr 38 tx lcdca abmdr table 16-8. peripheral identity values pid direction peripheral in stance peripheral register
340 42023e?sam?07/2013 atsam4l8/l4/l2 17. usb device and embedded host interface (usbc) rev: 3.1.0.19 17.1 features ? compatible with the usb 2.0 specification ? supports full (12m bit/s) and low (1.5mbit/s) speed communication ? supports embedded host ? 8 physical pipes/endpoints in ping-pong mode ? flexible pipe/endpoint configuration and reallocation of data buffers in embedded ram ? supports an endpoint numbering range from 0 to 15, in both i/o directions ? supports an infinite number of virtual pipes (alternate pipe) ? up to two memory banks per pipe/endpoint ? built-in dma with multi-packet support through ping-pong mode ? on-chip transceivers with built-in pull-ups and pull-downs ? on-chip embedded host pad wit h a vbus analog comparator 17.2 overview the universal serial bus interface (usbc) modu le complies with the universal serial bus (usb) 2.0 specification supporting both the device and the embedded host mode. each pipe/endpoint can be configured into one of several transfer types. it can be associated with one or more memory banks (located inside the embedded system or cpu ram) used to store the current data payload. if two banks are used (?ping-pong? mode), then one bank is read or written by the cpu (or any other ahb master) while the other is read or written by the usbc core. table 17-1 describes the hardware configuration of the usbc module. 17.3 block diagram the usbc interfaces a usb link with a data flow stored in the embedded ram (cpu or ahb). the usbc requires a 48mhz 0.25% reference cl ock, which is the usb generic clock. for more details see ?clocks? on page 343 . the 48mhz clock is used to generate either a 12mhz full-speed or a 1.5mhz low-speed bit clock from the received usb differential data, and to trans- mit data according to full- or low-speed usb devic e tolerances. clock recovery is achieved by a digital phase-locked loop (a dpll, not represented) in the usbc module, which complies with the usb jitter specifications. table 17-1. description of usb pipes/endpoints pipe/endpoint mnemonic max. size number of available banks type 0 pep0 1023 bytes 1 control/is ochronous/bulk/interrupt 1 pep1 1023 bytes 2 control/is ochronous/bulk/interrupt 2 pep2 1023 bytes 2 control/is ochronous/bulk/interrupt ... ... ... ... ... 7 pep7 1023 bytes 2 control/is ochronous/bulk/interrupt
341 42023e?sam?07/2013 atsam4l8/l4/l2 the usbc module consists of: ? hsb master interface ?user interface ? usb core ? transceiver pads figure 17-1. usbc block diagram interrupt controller usb interrupts dm usb gpio controller dp user interface scif gclk_usbc @ 48 mhz apb usb 2.0 co r e usb clock domain system clock domain ahb hsb master usb_id usb_vbus
342 42023e?sam?07/2013 atsam4l8/l4/l2 17.4 i/o lines description table 17-2. i/o lines description pin name pin description type active level dm data -: differential data line - port input/output dp data +: differential data line + port input/output
343 42023e?sam?07/2013 atsam4l8/l4/l2 17.5 product dependencies in order to use this module, other parts of the system must be configured correctly, as described below. 17.5.1 i/o lines the usbc pins may be multiplexed with the i/o controller lines. the user must first configure the i/o controller to assign the desired usbc pins to their peripheral functions. the usb vbus and id pin lines should be connected to gpio pins and the user should monitor this with software. 17.5.2 power management if the cpu enters a power save mode that disabl es clocks used by th e usbc, the usbc will stop functioning and resume operation after the system wakes up from power save mode. 17.5.3 clocks the usbc has two bus clocks connected: one high speed bus clock (clk_usbc_ahb) and one peripheral bus clock (clk_usbc_apb). these clocks are generated by the power man- ager. both clocks are enabled at reset, and can be disabled by the power manager. it is recommended to disable the usbc before disabling the clocks, to avoid freezing the usbc in an undefined state. to follow the usb data rate at 12mbit/s in full-speed mode, the clk_usbc_ahb clock should be at minimum 12mhz. the 48mhz usb clock is generated by a dedicated generic clock from the scif module. before using the usb, the user must ensure that th e usb generic clock (gclk_usbc) is enabled at 48mhz in the scif module. 17.5.4 interrupts the usbc interrupt request line is connected to the nvic. using the usbc interrupt requires the nvic to be programmed first. the usbc asynchronous interrupts can wake the cpu from any power save mode: ? the id transition interrupt (idti) ? the wakeup interrupt (wakeup) ? the host wakeup interrupt (hwupi)
344 42023e?sam?07/2013 atsam4l8/l4/l2 17.6 functional description 17.6.1 usb general operation 17.6.1.1 initialization after a hardware reset, the usbc is disabled. when enabled, the usbc runs in either device mode or in host mode according to the id detection. the usbc mode (usbcon.uimod) should be configured to set the usbc controller in either host mode or device mode. figure 17-2. general states after a hardware reset, the usbc is in the reset state. in this state: ? the module is disabled. the usbc enable bit in the general control register (usbcon.usbe) is reset. ? the module clock is stopped in order to minimize power consumption. the freeze usb clock bit in usbcon (usbcon.frzclk) is set. ? the usb pad is in suspend mode. ? the internal states and registers of the device and host modes are reset. ? the freeze usb clock (frzclk), usbc enable (usbe), usbc mode (uimod) in usbcon, and the low-speed mode bit in the device general control register (udcon.ls) can be written to by software, so that the user can configure pads and speed before enabling the module. these values are only taken into account once the module has been enabled and unfrozen. after writing a one to usbcon.usbe, the usbc enters device or host mode (according to uimod) in idle state. refer to section 17.6.2 for the basic operation of the device mode. refer to section 17.6.3 for the basic operation of the host mode. the usbc can be disabled at any time by writin g a zero to usbcon.usbe, this acts as a hard- ware reset, except that the frzclk and uimod bits in usbcon, and the ls bits in udcon are not reset. device reset usbe = 0 usbe = 1 uimod = 1 usbc off: usbe = 0 clock stopped: frzclk = 1 usbe = 0 host usbe = 0 hw reset usbe = 1 uimod = 0
345 42023e?sam?07/2013 atsam4l8/l4/l2 17.6.1.2 interrupts one interrupt vector is assigned to the usbc. see section 17.6.2.19 and section 17.6.3.16 for further details about device and host interrupts. see section 17.5.4 for asynchronous interrupts. 17.6.1.3 frozen clock when the usb clock is frozen, it is still possibl e to access the following bits: uimod, frzclk, and usbe in the usbcon register, and ls in the udcon register. when frzclk is set, only the asynchronous interrupts can trigger a usb interrupt (see section 17.5.4 ). 17.6.1.4 speed control ? device mode when the usbc interface is in device mode, the speed selection is done by the udcon.ls bit, connecting an internal pull-up resistor to either dp (full-speed mode) or dm (low-speed mode). the ls bit shall be written before attaching the device, which can be simulated by clearing the udcon.detach bit. figure 17-3. speed selection in device mode ? host mode when the usbc interface is in host mode, internal pull-downs are enabled on both dp and dm. the interface detects the speed of the connected device and reflects this in the speed status field (usbsta.speed). 17.6.1.5 data management endpoints and pipe buffers can be allocated anywhere in the embedded memory (cpu ram or hsb ram). see ?ram management? on page 349 . r pu udcon.detach dp dm udcon.ls vbus
346 42023e?sam?07/2013 atsam4l8/l4/l2 17.6.1.6 pad suspend figure 17-4 illustrates the behavior of the usb pad in device mode. figure 17-4. pad behavior ? in idle state, the pad is in low power consumption mode. ? in active state, the pad is working. figure 17-5 illustrates the pad events le ading to a pad state change. figure 17-5. pad events the suspend interrupt bit in the device global interrupt register (udint.susp) is set when a usb suspend state has been detected on the usb bus. this event automatically puts the usb pad in the idle state. the detection of a non -idle event sets wakeup and wakes the usb pad. the pad goes to the idle state if the module is disabled or if udcon.detach is written to one. it returns to the active state when usbcon.usbe is written to one and detach is written to zero. idle active usbe = 1 & detach = 0 & suspend usbe = 0 | detach = 1 | suspend susp suspend detected cleared on wakeup wakeup detected cleared by software to acknowledge the interrupt wakeup pad state active idle active
347 42023e?sam?07/2013 atsam4l8/l4/l2 17.6.2 usbc device mode operation 17.6.2.1 device enabling in device mode, the usbc supports full- and low-speed data transfers. including the default control endpoint, a total of 8 endpoints are provided. they can be config- ured as isochronous, bulk or interrupt types, as described in table 17-1 on page 340 after a hardware reset, the usbc device mode is in the reset state (see section 17.6.1.1 ). in this state, the endpoint banks are disabled and neither dp nor dm are pulled up (detach is one). dp or dm will be pulled up according to the sele cted speed as soon as the detach bit is writ- ten to zero. see ?device mode? for further details. when the usbc is enabled (usbe is one) in device mode, it enters the idle state, minimizing power consumption. being in idle state does not require the usb clocks to be activated. the usbc device mode can be disabled or reset at any time by disabling the usbc (by writing a zero to usbe) or by enab ling host mode (id is zero). 17.6.2.2 usb reset the usb bus reset is initiated by a connected host and managed by hardware. when a usb reset state is detected on the usb bus, the following operations are performed by the controller: ? udcon register is reset except for the detach and spdconf bits. ? device frame number register (udfnum), endpoint n configuration register (uecfgn), and endpoint n control register (ueconn) registers are cleared. ? the data toggle sequencing in all the endpoints are cleared. ? at the end of the reset process, the end of reset (eorst) bit in the udint register is set. 17.6.2.3 endpoint activation when an endpoint is disabled (uerst.epenn = 0) the data toggl e sequence, endp oint n status set (uestan), and ueconn regist ers will be reset. the controller ignores all transactions to this endpoint as long as it is inactive. to complete an endpoint activation, the user should fill out the endpoint descriptor: see figure 17-6 on page 350 . 17.6.2.4 endpoint redirection by default, the redirected endpoint number (uecfgn.repnb) field is zero, and any transaction targeted to endpoint n will be associated to the physical endpoint n. by configuring the uecfgn.repnb field to a value m, any transaction targeted to this endpoint m will be redirected to the physical endpoint n. this allows two virtual endpoints, in and out, to be configured towards the same endpoint number. 17.6.2.5 data toggle sequence in order to respond to a clear_feature usb request without disabling the endpoint, the user can clear the data toggle sequence by writing a one to the reset data toggle set bit in the endpoint n control set regi ster (ueconnset.rstdts)
348 42023e?sam?07/2013 atsam4l8/l4/l2 17.6.2.6 busy bank enable in order to make an endpoint bank look busy regardless of its actual state, the user can write a one to the busy bank enable bit in the endpoint n control register (ueconnset.busy0/1es). if a busyne bit is set, any transaction to this bank will be rejected with a nak reply. 17.6.2.7 address setup the usb device address is set up according to the usb protocol. ? after all kinds of resets, the usb device address is 0. ? the host starts a setup transacti on with a set_address(addr) request. ? the user writes this address to the usb address field (udcon.uadd), and writes a zero to the address enable bit (udcon.adden), re sulting in the address remaining zero. ? the user sends a zero-length in packet from the control endpoint. ? the user enables the stored usb device address by writing a one to adden. once the usb device address is configured, the controller filters the packets to only accept those targeting the address stored in uadd. uadd and adden should not be written to simu ltaneously. they should be written sequentially, uadd field first. if uadd or adden is cleared, the default device address 0 is used. uadd and adden are cleared: ? on a hardware reset. ? when the usbc is disabled (usbe written to zero). ? when a usb reset is detected. 17.6.2.8 suspend and wakeup when an idle usb bus state has been detected for 3 ms, the controller sets the suspend (susp) interrupt bit in udint. in this case , the transceiver is suspended, reducing power consumption. to further reduce power consumption it is recommended to freeze the usb clock by writing a one to the freeze usb clock (frzclk) bit in usbcon when the usb bus is in suspend mode. the mcu can also enter the power save mode mode to further lower power consumption. to recover from the suspend mode, the user shall wait for the wakeup (wakeup) interrupt bit, which is set when a non-idle event is detected, and then write a zero to frzclk. as the wakeup interrupt bit in udint is set when a non-idle event is detected, it can occur regardless of whether the controller is in the suspend mode or not. 17.6.2.9 detach the reset value of the detach bit located in the udcon register, is one. it is possible to initiate a device re-enumeration simply by writing a one and then a zero to detach. detach acts on the pull-up connections of the dp and dm pads. see ?device mode? for fur- ther details.
349 42023e?sam?07/2013 atsam4l8/l4/l2 17.6.2.10 remote wakeup the remote wakeup request (also known as upstream resume) is the only request the device may send on its own initiative. this shoul d be preceded by a device_remote_wakeup request from the host. ? first, the usbc must have detected a ?suspend? state on the bus, i.e. the remote wakeup request can only be sent after a susp interrupt has been set. ? the user may then write a one to the remote wakeup (rmwkup) bit in udcon to send an upstream resume to the host initiating the wakeup. this will automatically be done by the controller after 5ms of inactivity on the usb bus. ? when the controller sends the upstream resume, the upstream resume (uprsm) interrupt is set and susp is cleared. ? rmwkup is cleared at the end of the transmitting upstream resume. ? in case of a rebroadcast resume initiated by the host, the end of resume (eorsm) interrupt is set when the rebroadcast resume is completed. 17.6.2.11 ram management endpoint data can be physically allocated anywhere in the embedded ram. the usbc control- ler accesses these endpoints directly through the hsb master (built-in dma). the usbc controller reads the usbc descriptors to know where each endpoint is located. the base address of the usbc descriptor (udesc.udesca) needs to be written by the user. the descriptors can also be allocated anywhere in the embedded ram. before using an endpoint, the user should setup the endpoint address for each bank. depending on the direction, the type, and the packet-mode (single or multi-packet), the user should also ini- tialize the endpoint packet size, and the endpoint c ontrol and status fields, so that the usbc controller does not compute random values from the ram. when using an endpoint the user should read t he uestax.currbk field to know which bank is currently being processed.
350 42023e?sam?07/2013 atsam4l8/l4/l2 figure 17-6. memory organization each descriptor of an endpoint n consists of four words. ? the address of the endpoint an d the bank used (epn_addr_bk0/1). ? the packet size information for the endpoint and bank (epn_pcksize_bk0/1): table 17-3. epn_pcksize_bk0/1 structure ? auto_zlp: auto zero length packet, see ?multi packet mode for in endpoints? on page 355 . ? multi_packet_size: see ?multi packet mode and single packet mode.? on page 352 . ? byte_count: see ?multi packet mode and single packet mode.? on page 352 . 31 30:16 15 14:0 auto_zlp multi_packet_size - byte_count epn bk0 ep0_c tr _sta_bk0 ep0_pcksize_bk0 ep0_addr_bk0 udesca growing memory addresses descriptor ep0 reserved ep0_c tr _sta_bk1 ep0_pcksize_bk1 ep0_ad d r _bk1 reserved bank0 bank1 +0x000 +0x004 +0x008 +0x00c +0x010 +0x014 +0x018 +0x01c ep1_c tr _sta_bk0 ep1_pcksize_bk0 ep1_addr_bk0 descriptor ep1 reserved ep1_c tr _sta_bk1 ep1_pcksize_bk1 ep1_ad d r _bk1 reserved bank0 bank1 +0x020 +0x024 +0x028 +0x02c +0x030 +0x034 +0x038 +0x03c epn_c tr _sta_bk0 epn_pcksize_bk0 epn_addr_bk0 reserved epn_c tr _sta_bk1 epn_pcksize_bk1 epn_ad d r _bk1 reserved bank0 bank1 descriptor epn epn bk1 usb descriptors usb buffers
351 42023e?sam?07/2013 atsam4l8/l4/l2 ? the control and status fields for the endpoint and bank (epn_ctr_sta_bk0/1): table 17-4. epn_ctr_sta_bk0 /1 structure ? underf: underflow status for isochronous in transfer. see ?data flow error? on page 358 . ? overf: overflow status for isochronous out transfer. see ?data flow error? on page 358 . ? crcerr: crc error status for isochronous out transfer. see ?crc error? on page 358 . ? stallrq_next: stall request for the next transfer. see ?stall request? on page 351 . 17.6.2.12 stall request for each endpoint, the stall management is performed using: ? the stall request (stallrq) bit in ueconn is set to initiate a stall request. ? the stalled interrupt (stalledi) bit in uestan is set when a stall handshake has been sent. to answer requests with a stall handshake, stallrq has to be set by writing a one to the stall request set (stallrqs) bit. all following requests will be discarded (rxouti, etc. will not be set) and handshaked with a stall until the stallrq bit is cleared, by receiving a new setup packet (for control endpoints) or by writing a one to the stall request clear (stall- rqc) bit. each time a stall handshake is sent, the stal ledi bit is set by the usbc and the epnint interrupt is set. the user can use the descriptor to manage stall requests. the usbc controller reads the epn_ctr_sta_bk0/1.stallrq_next bit after succ essful transactions and if it is one the usbc controller will set uecon.stallrq. the st all_next bit will be cleared upon receiving a setup transaction and the usbc cont roller will then clear the stallrq bit. ? special considerations for control endpoints if a setup packet is received at a control endpoint where a stall request is active, the received setup interrupt (rxstpi) bit in ue stan is set, and the stallrq and stalledi bits are cleared. it allows the setup to be always acked as required by the usb standard. this management simplifies the enumeration process management. if a command is not sup- ported or contains an error, the user requests a stall and can return to the main task, waiting for the next setup request. ? stall handshake and retry mechanism the retry mechanism has priority over the stall handshake. a stall handshake is sent if the stallrq bit is set and if there is no retry required. 31:19 18 17 16 15:1 0 status elements control elements - underf overf crcerr - stallrq_next
352 42023e?sam?07/2013 atsam4l8/l4/l2 17.6.2.13 multi packet mode and single packet mode. single packet mode is the default mode where one usb packet is managed per bank. the multi-packet mode allows the user to manage data exceeding the maximum endpoint size (uecfgn.epsize) for an endpoint bank across mult iple packets without software intervention. this mode can also be coupled with the ping-pong mode. ? for an out endpoint, the epn_pcksize_bk0/1.multi_packet_size field should be configured correctly to enable the multi-packet mode. see ?multi packet mode for out endpoints? on page 357 . for single packet mode, the multi_packet_size should be initialized either to 0 or configured with a packet size le ss than epsize (called a short packet), in order to allocate the exact amount of memory. in this case, any excessive words will not be written to memory. ? for an in endpoint, the epn_pcksize_bk0/1.byte_count field should be configured correctly to enable the multi-packet mode. see ?multi packet mode for in endpoints? on page 355 . for single packet mode, the byt e_count should be less than epsize. 17.6.2.14 management of control endpoints ? overview a setup request is always acked. when a new setup packet is received, the rxstpi is set, but not the received out data interrupt (rxouti) bit. the fifo control (fifocon) bit in ueconn is ir relevant for control endpoints. the user should therefore never use it for these endpoints. when read, this value is always zero. control endpoints are managed using: ? the rxstpi bit: is set when a new setup packet is received. this has to be cleared by firmware in order to acknowledge the packet and to free the bank. ? the rxouti bit: is set when a new out packet is received. this has to be cleared by firmware in order to acknowledge the packet and to free the bank. ? the transmitted in data interrupt (txini) bit: is set when the current bank is ready to accept a new in packet. this has to be cleared by firmware in order to send the packet. ? the user can ignore any incoming transaction except setup by setting the ueconn.noreply bit. this bit is automatically cleared by hardware when receiving a setup packet. ? control write figure 17-7 on page 353 shows a control write transaction. during the status stage, the control- ler will not necessarily send a nak on the first in token: ? if the user knows the exact number of descript or bytes that will be read, the status stage can be predicted, and a zero-length packet can be sent after the next in token. ? alternatively the bytes can be read until the naked in interrupt (nakini) is triggered, notifying that all bytes are sent by the host and that the transaction is now in the status stage.
353 42023e?sam?07/2013 atsam4l8/l4/l2 figure 17-7. control write ? control read figure 17-8 on page 353 shows a control read transaction. the usbc has to manage the simul- taneous write requests from the cpu and usb host. figure 17-8. control read a nak handshake is always generated as the first status stage command. the uestan.nakini bit is set. it allows the user to know that t he host aborts the in data stage. as a consequence, the user should stop processing the in data stage and should prepare to receive the out status stage by checking the uestan.rxouti bit. the out retry is always acked. this out recept ion sets rxouti. handle this with the follow- ing software algorithm: // process the in data stage set txini wait for rxouti (rising) or txini (falling) if rxouti is high, then process the out status stage if txini is low, then return to process the in data stage once the out status stage has been received, the usbc waits for a setup request. the setup request has priority over all other requests and will be acked. setup rxstpi rxouti txini usb bus hw sw out hw sw out hw sw in in nak sw data setup status setup rxstpi rxouti txini usb bus hw sw in hw sw in out out nak sw sw hw wr enable host wr enable cpu data setup status
354 42023e?sam?07/2013 atsam4l8/l4/l2 17.6.2.15 management of in endpoints ? overview in packets are sent by the usbc device controller upon in requests from the host. the endpoint and its descriptor in ram must be pre configured (see section ?ram manage- ment? on page 349 for more details). when the current bank is clear , the txini and fifo control (u econn.fifocon) bits will be set simultaneously. this triggers an epnint interrupt if the transmitted in data interrupt enable (txine) bit in ueconn is one. txini shall be cleared by software (by writing a one to the transmitted in data interrupt enable clear bit in the endpoint n control clear regi ster (ueconnclr.txinic)) to acknowledge the interrupt. this has no effect on the endpoint fifo. the user writes the in data to the bank referenced by the epn descriptor and allows the usbc to send the data by writing a one to the fifo control clear (ueconnclr.fifoconc) bit. this will also cause a switch to the next bank if the in endpoint is composed of multiple banks. the txini and fifocon bits will be updated accordingly. txini should always be cleared before clearing fifocon to avoid missing an txini event. figure 17-9. example of an in endpoint with one data bank figure 17-10. example of an in endpoint with two data banks in data (bank 0) ack txini fifocon hw write data to cpu bank 0 sw sw sw sw in nak write data to cpu bank 0 in data (bank 0) ack txini fifocon write data to cpu bank 0 sw sw sw sw in data (bank 1) ack write data to cpu bank 1 sw hw write data to cpu bank0
355 42023e?sam?07/2013 atsam4l8/l4/l2 ? detailed description the data is written according to this sequence: ? when the bank is empty, txini and fifocon are set, which triggers an epnint interrupt if txine is one. ? the user acknowledges the interrupt by clearing txini. ? the user reads the uestax.currbk fiel d to see which th e current bank is. ? the user writes the data to the current bank, located in ram as described by its descriptor: epn_addr_bk0/1. ? the user should write the size of the in packet into the usb descriptor: epn_pcksize_bk0/1.byte_count. ? the user allows the controller to send the bank contents and switches to the next bank (if any) by clearing fifocon. if the endpoint uses several banks, the current one can be written while the previous one is being read by the host. when the user clears fifo con, the next current bank may already be clear and txini is set immediately. an ?abort? stage can be produced when a zero-length out packet is received during an in stage of a control or isochronou s in transaction. the kill in ba nk (killbk) bit in ueconn is used to kill the last written bank. the best way to man age this abort is to apply the algorithm rep- resented on figure 17-11 on page 355 . see ?endpoint n control register? on page 401 for more details about the killbk bit. figure 17-11. abort algorithm ? multi packet mode for in endpoints in multi packet mode, the user can prepare n usb packets in the bank to be sent on a multiple in transaction. the packet sizes will equal ue cfgn.epsize unless t he auto_zlp option is endpoint abort abort done abort is based on the fact that no bank is busy, i.e., that nothing has to be sent disable the txini interrupt. eprstn = 1 nbusybk == 0? yes txinec = 1 no killbks = 1 killbk == 1? yes kill the last written bank. wait for the end of the procedure no
356 42023e?sam?07/2013 atsam4l8/l4/l2 set, or if the total byte count is not an integr al multiple of epsize, whereby the last packet should be short. to enable the multi packet mode, the user should configure the endpoint descriptor (epn_pcksize_bk0/1.byte_count) to the tota l size of the multi packet, which should be larger than the end point size (epsize). since the epn_pcksize_bk0/1.multi_packet_size is incremented (by the transmitted packet size) after each successful transaction, it should be set to zero when setting up a new multi packet transfer. the epn_pcksize_bk0/1.multi_packet_size is cleared by hardware when all the bank contents have been sent. the bank is consider ed as ready and the tx_in flag is set when: ? a short packet (smaller than epsize) has been transmitted. ? a packet has been successfully transmitted, the updated multi_packet_size equals the byte_count, and the auto_zlp field is not set. ? an extra zero length packet has been automatically sent for the last transfer of the current bank, if byte_count is a multiple of epsize and auto_zlp is set. 17.6.2.16 management of out endpoints ? overview the endpoint and its descriptor in ram must be pre configured, see section ?ram management? on page 349 for more details. when the current bank is full, the rxouti an d fifo control (ueconn.fifocon) bits will be set simultaneously. this trigge rs an epnint interrupt if the received out data interrupt enable (rxoute) bit in ueconn is one. rxouti shall be cleared by soft ware (by writing a one to the re ceived out data interrupt clear (rxoutic) bit) to acknowledge the interrupt. this has no effect on the endpoint fifo. the user reads the out data from the ram and clears the fifocon bit to free the bank. this will also cause a switch to the next bank if th e out endpoint is compos ed of multiple banks. rxouti should always be cleared before clear ing fifocon to avoid missing an rxouti event. figure 17-12. example of an out endpoint with one data bank out data (bank 0) ack rxouti fifocon hw out data (bank 0) ack hw sw sw sw read data from cpu bank 0 read data from cpu bank 0 nak
357 42023e?sam?07/2013 atsam4l8/l4/l2 figure 17-13. example of an out endpoint with two data banks ? detailed description before using the out endpoint, one should properly initialize its descriptor for each bank. see figure 17-6 on page 350 . the data is read, according to this sequence: ? when the bank is full, rxouti and fifocon ar e set, which triggers an epnint interrupt if rxoute is one. ? the user acknowledges the interrupt by writing a one to rxoutic in order to clear rxouti. ? the user reads the uestax.currbk fiel d to know the current bank number. ? the user reads the byte count of the current bank from the descriptor in ram (epn_pcksize_bk0/1.byte_count) to know how many bytes to read. ? the user reads the data in the current bank, located in ram as described by its descriptor: epn_addr_bk0/1. ? the user frees the bank and switches to the next bank (if any) by clearing fifocon. if the endpoint uses several banks, the current one can be read while the next is being written by the host. when the user clears fifocon, the following bank may already be ready and rxouti will be immediately set. ? multi packet mode for out endpoints in multi packet mode, the user can extend the si ze of the bank allowing the storage of n usb packets in the bank. to enable the multi packet mode, the user should configure the endpoint descriptor (epn_pcksize_bk0/1.multi_packet_size) to match the size of the multi packet. this value should be a multiple of the endpoint size (uecfgn.epsize). since the epn_pcksize_bk0/1.byte_count is in cremented (by the received packet size) after each successful transaction, it should be set to zero when setting up a new multi packet transfer. as for single packet mode, the number of received data bytes is stored in the byte_cnt field. the bank is considered as ?valid? and the rx_out flag is set when: out data (bank 0) ack rxouti fifocon hw out data (bank 1) ack sw sw read data from cpu bank 0 hw sw read data from cpu bank 1
358 42023e?sam?07/2013 atsam4l8/l4/l2 ? a packet has been successfully received and the updated byte_count equals the multi_packet_size. ? a short packet (smaller than epsize) has been received. 17.6.2.17 data flow error this error exists only for isochronous in/out endpoints. it sets the errorflow interrupt (errorfi) bit in uestan, which triggers an epnin t interrupt if the errorflow interrupt enable (errorfe) bit is one. the user can chec k the epn_ctr_sta_bk0/1.underf and overf bits in the endpoint descriptor to see which current bank has been affected. ? an underflow can occur during in stage if the host attempts to read from an empty bank. a zero-length packet is then automatically sent by the usbc. the endpoint descriptor epn_ctr_sta_bk0/1.underf points out the bank from which the in data should have originated. if a new successful transaction occurs, the underf bit is overwritten to 0 only if the uestan.errorfi is cleared. ? an overflow can occur during the out stage if the host tries to send a packet while the bank is full. typically this occurs when a cpu is no t fast enough. the packet data is not written to the bank and is lost. the endpoint descriptor epn_ctr_sta_bk0/1.overf points out which bank the out data was destined to. if the uestan.errorfi bit is cleared and a new transaction is su ccessful, the overf bit will be overwritten to zero. 17.6.2.18 crc error this error exists only for isochronous out endpoints. it sets the crc error interrupt (crcerri) bit in uestan, which triggers an epnint interrupt if the crc error interrupt enable (crcerre) bit is one. a crc error can occur during an isochronous out stage if the usbc detects a corrupted received packet. the out packet is stored in the bank as if no crc error had occurred (rxouti is set). the user can also check the endpoint descriptor to see which current bank is impacted by the crc error by reading epn_ctr_sta_bk0/1.crcerr. 17.6.2.19 interrupts there are two kinds of device interrupts: processing, i.e. their generation is part of the normal processing, and exception, i.e. errors not related to cpu exceptions. ? global interrupts the processing device global interrupts are: ? the suspend (susp) interrupt ? the start of frame (sof) interrupt with no frame number crc error (the frame number crc error (fncerr) bit in the device fram e number (udfnum) register is zero) ? the end of reset (eorst) interrupt ? the wakeup (wakeup) interrupt ? the end of resume (eorsm) interrupt ? the upstream resume (uprsm) interrupt ? the endpoint n (epnint) interrupt the exception device global interrupts are:
359 42023e?sam?07/2013 atsam4l8/l4/l2 ? the start of frame (sof) interrupt with a frame number crc error (fncerr is one) ? endpoint interrupts the processing device endpoint interrupts are: ? the transmitted in data interrupt (txini) ? the received out data interrupt (rxouti) ? the received setup interrupt (rxstpi) ? the number of busy banks (nbusybk) interrupt the exception device endpoint interrupts are: ? the errorflow interrupt (errorfi) ? the naked out interrupt (nakouti) ? the naked in interrupt (nakini) ? the stalled interrupt (stalledi) ? the crc error interrupt (crcerri)
360 42023e?sam?07/2013 atsam4l8/l4/l2 17.6.3 usb host operation 17.6.3.1 host enabling figure 17-14 on page 360 describes the usbc host mode main states. figure 17-14. host mode states after a hardware reset, the usbc host mode is in the reset state (see section 17.6.1.1 ). when the usbc is enabled (usbcon.usbe = 1) in host mode (usbcon.uimod = 0) it enters idle state. as soon as the usbsta.vbusrq bit is one, usbc waits for a device connection. once a device is connected, the usbc enters the ready state, which does not require the usb clock to be activated. in host mode the usbc will sus pend the usb bus by not transmit ting any start of frame (sof) packets (the start of frame generation enable bit in the host global interrupt register uhcon.sofe is zero). the usbc enters the suspend state when the usb bus is suspended, and exits when sof generation is resumed. 17.6.3.2 device detection a device is detected by the usbc in host mode when dp or dm are not tied low, i.e., when a device dp or dm pull-up resistor is connected. to enable this detection, the host controller has to be notified that the vbus is powered, which is done when usbsta.vbusrq is one. the device disconnection is detected by the host controller when both dp and dm are pulled down. 17.6.3.3 description of pipes in host mode, the term ?pipe? is used instead of ?endpoint?. a host pipe corresponds to a device endpoint, as illustrated by figure 17-15 on page 361 from the usb specification. ready idle device disconnection device connection macro off clock stopped device disconnection suspend sofe = 1 sofe = 0
361 42023e?sam?07/2013 atsam4l8/l4/l2 figure 17-15. usb communication flow in host mode, the usbc associates a pipe to a device endpoint, according to the device config- uration descriptors. 17.6.3.4 usb reset the usbc sends a usb reset signal when the user writes a one to the send usb reset bit (uhcon.reset). when the usb reset has been sent, the usb reset sent interrupt bit in the host global interrupt register (uhint.rsti) is set an d all the pipes will be disabled. if the bus was previously in a suspended state (uhcon.sofe is zero) the usbc will switch it to the resume state, causing the bus to asynchronously trigger the host wakeup interrupt (uhint.hwupi). the sofe bit will be set in order to generate sof?s immediately after the usb reset. 17.6.3.5 pipe activation a disabled pipe is inactive, an d will be reset along with its cont ext registers (upconn, upstan, upinrqn, and upcfgn). enabling a pipe is done by writing a one to the pipe n enable bit in the pipe enable/reset register (uprst.penn). when starting an enumeration, the user gets the device descr iptor by sending an get_descriptor usb request. this descripto r contains the maximal packet size of the device default control endpoint (bmaxpacketsize0) which the user should use to reconfigure the size of the default control pipe. 17.6.3.6 address setup once the device has answered the first host requests with the default device address 0, the host assigns a new address to the device. the host co ntroller has to send a usb reset to the device and a set_address(addr) setup request with the new address to be used by the device. once this setup transaction is over, the user writes to the device address field in the ?control and status 1 of endpoint n? word of the host?s pipe n in the usb descriptor (pn_ctr_sta1.pdaddr). all foll owing requests by this pipe will be performed using this new address.
362 42023e?sam?07/2013 atsam4l8/l4/l2 17.6.3.7 remote wakeup writing uhcon.sofe to zero when in host mode will cause the usbc to cease sending sof?s on the usb bus and enter the su spend state. the usb device will enter the susp end state 3ms later. the device can awaken the host by sending an upstream resume (remote wakeup feature). when the host detects a non-idle state on the usb bus, it sets the host wakeup interrupt bit (uhint.hwupi). if the non-idle bus state corresponds to an upstream resume (k state), the upstream resume received interrupt bit (uhint.rxrsmi) is set and the user has to generate a downstream resume within 1ms and for at least 20ms. it is required to first enter the ready state by writing a one to uhcon.sofef and then writing a one to the send usb resume bit (uhcon.resume). 17.6.3.8 ram management pipe data can be physically allocated anywhere in the embedded ram. the usbc controller accesses the pipes directly through the hsb master (built-in dma). the usbc controller reads the usbc descriptors to know the location of each pipe. the base address of this usbc descriptor (udesc.udesca) needs to be written by the user. the descriptors can also be allocated anywhere in the embedded ram. before using a pipe, the user should setup the data address for each bank. depending on the direction, pipe type, targeted device address, targeted endpoint number, and packet-mode (sin- gle or multi-packet), the user should also initialize the pipe packet size and the pipe control and status field, so that the usb controller does not compute random values from the ram. when using a pipe, the user should read the upstax.currbk fiel d to know which bank is cur- rently processed.
363 42023e?sam?07/2013 atsam4l8/l4/l2 figure 17-16. memory organization each pipe n descriptor bank consists of four words. ? the address of the pipe and bank used (pn_addr_bk0/1). ? the packet size information for the pipe and bank (pn_pcksize_bk0/1): table 17-5. pn_pcksize_bk0/1 structure ? auto_zlp: auto zero length packet, see ?multi packet mode for out pipes? on page 368 . ? multi_packet_size: see ?multi packet mode and single packet mode.? on page 352 . ? byte_count: see ?multi packet mode and single packet mode.? on page 352 . 31 30:16 15 14:0 auto_zlp multi_packet_size - byte_count pn bk0 p0_ctr_sta_bk0 p0_pcksize_bk0 p0_addr_bk0 udesca growing memory addresses descriptor p0 p0_ctr_sta1 p0_ctr_sta_bk1 p0_pcksize_bk1 p0_addr_bk1 reserved bank0 bank1 +0x000 +0x004 +0x008 +0x00c +0x010 +0x014 +0x018 +0x01c p1_ctr_sta_bk0 p1_pcksize_bk0 p1_addr_bk0 descriptor p1 p1_ctr_sta1 p1_ctr_sta_bk1 p1_pcksize_bk1 p1_addr_bk1 reserved bank0 bank1 +0x020 +0x024 +0x028 +0x02c +0x030 +0x034 +0x038 +0x03c pn_ctr_sta_bk0 pn_pcksize_bk0 pn_addr_bk0 pn_ctr_sta1 pn_ctr_sta_bk1 pn_pcksize_bk1 pn_addr_bk1 reserved bank0 bank1 descriptor pn pn bk1 usb descriptors usb buffers
364 42023e?sam?07/2013 atsam4l8/l4/l2 ? the control and status fields for the pipe and bank (pn_ctr_sta_bk0/1): table 17-6. pn_ctr_sta_bk0 /1 structure ? underf: underflow status for isochronous/interrupt in transfers. this status bit is set by hardware at the current bank (where the in packet should have been stored). when a new successful transaction occurs this bit is overwritten to zero if upstax.errorfi has previously been cleared by software. see ?data flow error? on page 368 . ? overf: overflow status for isochronous/interrupt out transfers. this status bit is set by hardware at the current bank (where the out packet should have been loaded). when a new successful transaction occurs this bit is overwritten to zero if upstax.errorfi has previously been cleared by software. see ?data flow error? on page 368 . ? crcerr: crc error status for isochronous in transfers. see ?crc error? on page 368 . ? the control and status 1 of endpoint n (pn_ctr_sta1): table 17-7. pn_ctr_sta1 structure ? persta: pipe error status. see ?persta structure? table. ? permax : should be set by the user. if the pipe error counter (see figure 17-8 on page 364 ) is larger than permax, th e upstax.perri bit is set. ? pepnum : should be set by the user. endpoint number for this pipe. ? pdaddr: should be set by the user. device address for this pipe. table 17-8. persta structure this field can be cleared by software. to avoid read-modify-write issues, the user should: freeze the pipe, wait until the upstax.pfreeze is one, clear the persta field in memory, and then unfreeze the pipe. ? ercnt: pipe error counter. ? crc16er: is set if a crc16 error occurs during an isochronous in transaction. ? touter: is set if a time-out error occurs during a usb transaction. ? pider: is set if a pid error occurs during a usb transaction. ? dapider: is set if a data pid error occurs during a usb transaction. 31:19 18 17 16 15:0 status control - underf overf crcerr - 31:24 23:16 15:12 11:8 7 6:0 status control - persta permax pepnum - pdaddr 23:212019181716 ercnt crc16er touter pider dapider dtgler
365 42023e?sam?07/2013 atsam4l8/l4/l2 ? dtgler: is set if a data toggle error occurs during a usb transaction. 17.6.3.9 multi packet mode and single packet mode. see ?multi packet mode and single packet mode.? on page 352 and just consider that an out pipe corresponds to an in endpoint, and an in pipe corresponds to an out endpoint. 17.6.3.10 management of control pipes a control transaction is composed of three stages: ? setup ? data (in or out) ? status (out or in) the user has to change the pipe token according to each stage. for control pipes only, the token is assigned a specific initial da ta toggle sequence: ? setup: data0 ? in: data1 ? out: data1 17.6.3.11 management of in pipes ? overview in packets are sent by the usb device contro ller upon in requests from the host. all the data can be read, acknowledging whether or not the bank is empty. ? detailed description the pipe and its descriptor in ram must be pre configured. the host can request data from the device in tw o modes, selected by writing to the in request mode bit in the pipe n in request register (upinrqn.inmode): ? when inmode is written to zero, the usbc will perform inrq in re quests before freezing the pipe. ? when inmode is written to one, the usbc will perf orm in requests as long as the pipe is not frozen by the user. the generation of in requests starts when t he pipe is unfrozen (upconn.pfreeze is zero). when the current bank is full, the rxini and fifo control (upstan.fifo con) bits will be set simultaneously. this triggers a pnint interrupt if the received in data interrupt enable bit (upconn.rxine) is one. rxini shall be cleared by softwa re to acknowledge the interrupt. this is done by writing a one to the received in data interrupt clear bit in the pipe n control clear register (upconnclr.rxinic), which does not affect the pipe fifo. the user reads the byte count of the current bank from the descriptor in ram (pn_pcksize_bk0/1.byte_count) to know how many bytes should be read. the user reads the in da ta from the ram and clears the fifo con bit to free the bank. this will also cause a switch to the next bank if the in endpoint is composed of multiple banks. the rxini and fifocon bits will be updated accordingly.
366 42023e?sam?07/2013 atsam4l8/l4/l2 rxini should always be cleared before cleari ng fifocon to avoid missing an rxini event. figure 17-17. example of an in pipe with one data bank figure 17-18. example of an in pipe with two data banks ? multi packet mode for in pipes see ?multi packet mode for out endpoints? on page 357 and just replace out endpoints with in pipe. 17.6.3.12 management of out pipes ? overview out packets are sent by the host. all the data can be written, acknowledging whether or not the bank is full. ? detailed description the pipe and its descriptor in ram must be pre configured. when the current bank is clear, the transmitted out data interrupt (txouti) and fifo control (upstan.fifocon) bits will be set simultaneously. this tr iggers a pnint inte rrupt if the trans- mitted out data interrupt enable bit (upconn.txoute) is one. in data (bank 0) ack rxini fifocon hw in data (bank 0) ack hw sw sw sw read data from cpu bank 0 read data from cpu bank 0 in data (bank 0) ack rxini fifocon hw in data (bank 1) ack sw sw read data from cpu bank 0 hw sw read data from cpu bank 1
367 42023e?sam?07/2013 atsam4l8/l4/l2 txouti shall be cleared by software to acknowledge the interrupt. this is done by writing a one to the transmitted out data interrupt clear bit (upconnclr.txoutic), which does not affect the pipe fifo. the user writes the out data to the bank refer enced to by the pepn descriptor and allows the usbc to send the data by writing a one to the fifo control clear (upconnclr.fifoconc) bit. this will also cause a switch to the next bank if the out pipe is comp osed of multiple banks. the txouti and fifocon bits will be updated accordingly txouti shall always be cleared before clearing fifocon to avoid missing an txouti event. note that if the user decides to switch to the suspend state (by writing a zero to uhcon.sofe) while a bank is ready to be sent, the usbc au tomatically exits this state and sends the data. figure 17-19. example of an out pipe with one data bank figure 17-20. example of an out pipe with two data banks and no bank switching delay out data (bank 0) ack txouti fifocon hw write data to cpu bank 0 sw sw sw sw out write data to cpu bank 0 out data (bank 0) ack txouti fifocon write data to cpu bank 0 sw sw sw sw write data to cpu bank 1 sw hw write data to cpu bank0 out data (bank 1) ack
368 42023e?sam?07/2013 atsam4l8/l4/l2 figure 17-21. example of an out pipe with two data banks and a bank switching delay ? multi packet mode for out pipes see section ?multi packet mode for in endpoints? on page 355 and just replace in endpoints with out pipe. 17.6.3.13 alternate pipe the user has the possibility to r un sequentially several logical pi pes on the same physical pipe. before switching pipe, the user should save the pipe context (upcfgn, upconn, upstan, and the pipe descriptor table). after switching pipe, the user should restore the pipe context, current bank number, and the cur- rent data toggle by using the upco nn.initdtgl and upconn.initbk bits. 17.6.3.14 data flow error this error exists only for isochronous and interrupt pipes for both in and out directions. it sets the errorflow interrupt (errorfi) bit in upstan, which triggers an pnint interrupt if the error- flow interrupt enable (errorfe) bit is one. the user can check the pn_ctr_sta_bk0/1.underf and overf bits in the pipe descriptor to see which current bank has been affected. ? an overflow can occur during an out stage if the host attempts to send data from an empty bank. the pipe descriptor pn_ctr_sta_bk0/1 .overf points out the bank from which the out data should have originated. if the u pstan.errorfi bit is cleared and a new transaction is su ccessful, the pn_ctr_sta_bk0/1 .overf bit will be cleared. ? an underflow can occur during an in stage if the device tries to send a packet while the bank is full. typically this occurs when a cpu is no t fast enough. the packet data is not written to the bank and is lost. the pipe descriptor pn_ctr_sta_bk0/1.underf points out which bank the out data was destined to. if upstan .underfi is zero and a new successful transaction occurs, pn_ctr_sta _bk0/1.underf will be cleared. 17.6.3.15 crc error this error exists only for isoc hronous in pipes. it sets the cr c error interrupt bit (crcerri), which triggers a pnint interrup t if the crc error interrupt enable bit (upconn.crcerre) is one. out data (bank 0) ack txouti fifocon write data to cpu bank 0 sw sw sw sw out data (bank 1) ack write data to cpu bank 1 sw hw write data to cpu bank0
369 42023e?sam?07/2013 atsam4l8/l4/l2 a crc error can occur during the in stage if the usbc detects a corrupted packet. the in packet will remain st ored in the bank and rxini will be set. the user can check the pn_ctr_sta_bk0/1.crcerr bit in the pipe descriptor to see which current bank has been affected. 17.6.3.16 interrupts there are two kinds of host interrupts: processing, i.e. their generation is part of the normal pro- cessing, and exception, i.e. errors not related to cpu exceptions. ? global interrupts the processing host global interrupts are: ? the device connection interrupt (dconni) ? the device disconnection interrupt (ddisci) ? the usb reset sent interrupt (rsti) ? the downstream resume sent interrupt (rsmedi) ? the upstream resume received interrupt (rxrsmi) ? the host start of frame interrupt (hsofi) ? the host wakeup interrupt (hwupi) ? the pipe n interrupt (pnint) there is no exception host global interrupt. ? pipe interrupts the processing host pipe interrupts are: ? the received in data interrupt (rxini) ? the transmitted out data interrupt (txouti) ? the transmitted setup interrupt (txstpi) ? the number of busy banks (nbusybk) interrupt the exception host pipe interrupts are: ? the errorflow interrupt (errorfi) ? the pipe error interrupt (perri) ? the naked interrupt (nakedi) ? the received stalled interrupt (rxstalldi) ? the crc error interrupt (crcerri)
370 42023e?sam?07/2013 atsam4l8/l4/l2 17.7 user interface table 17-9. usbc register memory map offset register register name access reset 0x0000 device general control register udcon read/write 0x00000100 0x0004 device global interrupt register udint read-only 0x00000000 0x0008 device global interrupt clear register udintclr write-only 0x00000000 0x000c device global interrupt se t register udintset write-only 0x00000000 0x0010 device global interrupt enable register udinte read-only 0x00000000 0x0014 device global interrupt enable clear register udinteclr write-only 0x00000000 0x0018 device global interrupt enable set register udinteset write-only 0x00000000 0x001c endpoint enable/reset register uerst read/write 0x00000000 0x0020 device frame number register udfnum read-only 0x00000000 0x0100 + n*4 endpoint n configuration register uecfgn read/write 0x00000000 0x0130 + n*4 endpoint n status register uestan read-only 0x00000100 0x0160 + n*4 endpoint n status clear register uestanclr write-only 0x00000000 0x0190 + n*4 endpoint n status set register uestanset write-only 0x00000000 0x01c0 + n*4 endpoint n control register ueconn read-only 0x00000000 0x01f0 + n*4 endpoint n control set register ueconnset write-only 0x00000000 0x0220 + n*4 endpoint n control clear register ueconnclr write-only 0x00000000 0x0400 host general control register uhcon read/write 0x00000000 0x0404 host global interrupt register uhint read-only 0x00000000 0x0408 host global interrupt clear register uhintclr write-only 0x00000000 0x040c host global interrupt set register uhintset write-only 0x00000000 0x0410 host global interrupt enable register uhinte read-only 0x00000000 0x0414 host global interrupt enable cl ear register uhinteclr write-only 0x00000000 0x0418 host global interrupt enable set register uhinteset write-only 0x00000000 0x0041c pipe enable/reset register uprst read/write 0x00000000 0x0420 host frame number r egister uhfnum read/write 0x00000000 0x0424 host start of frame contro l register uhsofc read/write 0x00000000 0x0500 + n*4 pipe n configuration register upcfgn read/write 0x00000000 0x0530 + n*4 pipe n status register upstan read-only 0x00000000 0x0560 + n*4 pipe n status clear register upstanclr write-only 0x00000000 0x0590 + n*4 pipe n status set register upstanset write-only 0x00000000 0x05c0 + n*4 pipe n control register upconn read-only 0x00000000 0x05f0 +n*4 pipe n control set register upconnset write-only 0x00000000 0x0620 + n*4 pipe n control clear register upconnclr write-only 0x00000000 0x0650 + n*4 pipe n in request register upinrqn read/write 0x00000001 0x0800 general control register usbcon read/write 0x03004000
371 42023e?sam?07/2013 atsam4l8/l4/l2 note: 1. the reset values are device specific. refer to the module configuration section at the end of this chapter. 0x0804 general status regi ster usbsta read-only 0x00000000 0x0808 general status clear regi ster usbstaclr write-only 0x00000000 0x080c general status set regi ster usbstaset writ e-only 0x00000000 0x0818 ip version register uvers read-only - (1) 0x081c ip features register ufeatures read-only - (1) 0x0820 ip pb address size register uaddrsize read-only - (1) 0x0824 ip name register 1 uname1 read-only - (1) 0x0828 ip name register 2 uname2 read-only - (1) 0x082c usb finite state machine stat us register usbfsm read-only 0x00000009 0x0830 usb descriptor address udesc read/write 0x00000000 table 17-9. usbc register memory map offset register register name access reset
372 42023e?sam?07/2013 atsam4l8/l4/l2 17.7.1 usb general registers 17.7.1.1 general control register name: usbcon access type: read/write offset: 0x0800 reset value: 0x03004000 ? uimod: usbc mode 0: the module is in usb host mode. 1: the module is in usb device mode. this bit can be written to even if usbe is zero or frzclk is one. disabling the usbc (by writing a zero to the usbe bit) does not reset this bit. ? usbe: usbc enable writing a zero to this bit will disable the usbc, usb transceiver , and usb clock inputs. this will over-ride frzclk settings bu t not affect the value. unless explicitly stated , all registers will become reset and read-only. writing a one to this bit will enable the usbc. 0: the usbc is disabled. 1: the usbc is enabled. this bit can be written to even if frzclk is one. ? frzclk: freeze usb clock writing a zero to this bit will enable usb clock inputs. writing a one to this bit will disable usb clock inputs. the resume detection will remain active. unless explicitly stated, all registers will become read-only. 0: the clock inputs are enabled. 1: the clock inputs are disabled. this bit can be written to even if usbe is zero. 31 30 29 28 27 26 25 24 ------uimod- 23 22 21 20 19 18 17 16 ------ 15 14 13 12 11 10 9 8 usbefrzclk------ 76543210 --------
373 42023e?sam?07/2013 atsam4l8/l4/l2 17.7.1.2 general status register register name: usbsta access type: read-only offset: 0x0804 reset value: 0x00010000 ? suspend: suspend us b transceiver state this bit is cleared when the usb transceiver is switched off. this bit is cleared when the usb transceiver is switched on. ? clkusable: generic clock usable this bit is cleared when the usb generic clock is not usable. this bit is set when the usb generic clock (that should be 48mhz) is usable. ? speed: speed status this field is set according to the controller speed mode. ? vbusrq: vbus request 0: usbc is notified that the vb us on the usb line is not powered. 1: usbc is notified that the vbus on the usb line is powered. this bit is cleared when usbstaclr.vbusrqc is written to one. this bit is set when usbstaset.vbusrqs is written to one. this bit should only be used in host mode. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 - - - - - - - suspend 15 14 13 12 11 10 9 8 - clkusable speed - - vbusrq - 76543210 ------- speed speed status 00 full-speed mode 01 reserved 10 low-speed mode 11 reserved
374 42023e?sam?07/2013 atsam4l8/l4/l2 17.7.1.3 general status clear register register name: usbstaclr access type: write-only offset: 0x0808 reset value: 0x00000000 writing a zero to a bit in this register has no effect. writing a one to a bit in this register will clear the corresponding bit in usbsta. these bits always read as zero. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 ------vbusrqc- 76543210 --------
375 42023e?sam?07/2013 atsam4l8/l4/l2 17.7.1.4 general status set register register name: usbstaset access type: write-only offset: 0x080c reset value: 0x00000000 writing a zero to a bit in this register has no effect. writing a one to a bit in this register will set the corresponding bit in usbsta. these bits always read as zero. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 ------vbusrqs- 76543210 --------
376 42023e?sam?07/2013 atsam4l8/l4/l2 17.7.1.5 version register register name: uvers access type: read-only offset: 0x0818 reset value: - ? variant: variant number reserved. no functionality associated. ? version: version number version number of the module. no functionality associated. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 ---- variant 15 14 13 12 11 10 9 8 - - - - version[11:8] 76543210 version[7:0]
377 42023e?sam?07/2013 atsam4l8/l4/l2 17.7.1.6 features register register name: ufeatures access type: read-only offset: 0x081c reset value: - ? eptnbrmax: maximal number of pipes/endpoints this field indicates the number of hardware-implemented pipes/endpoints: 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------- 76543210 - - - - eptnbrmax
378 42023e?sam?07/2013 atsam4l8/l4/l2 17.7.1.7 address size register register name: uaddrsize access type: read-only offset: 0x0820 reset value: - ? uaddrsize: ip pb address size this field indicates the size of the pb address space reserved for the usbc ip interface. 31 30 29 28 27 26 25 24 uaddrsize[31:24] 23 22 21 20 19 18 17 16 uaddrsize[23:16] 15 14 13 12 11 10 9 8 uaddrsize[15:8] 76543210 uaddrsize[7:0]
379 42023e?sam?07/2013 atsam4l8/l4/l2 17.7.1.8 ip name register 1 register name: uname1 access type: read-only offset: 0x0824 reset value: - ? uname1: ip name part one this field indicates the first part of the ascii-encoded name of the usbc ip. 31 30 29 28 27 26 25 24 uname1[31:24] 23 22 21 20 19 18 17 16 uname1[23:16] 15 14 13 12 11 10 9 8 uname1[15:8] 76543210 uname1[7:0]
380 42023e?sam?07/2013 atsam4l8/l4/l2 17.7.1.9 ip name register 2 register name: uname2 access type: read-only offset: 0x0828 reset value: ? uname2: ip name part two this field indicates the second part of the ascii-encoded name of the usbc ip. 31 30 29 28 27 26 25 24 uname2[31:24] 23 22 21 20 19 18 17 16 uname2[23:16] 15 14 13 12 11 10 9 8 uname2[15:8] 76543210 uname2[7:0]
381 42023e?sam?07/2013 atsam4l8/l4/l2 17.7.1.10 finite state machine status register register name: usbfsm access type: read-only offset: 0x082c reset value: 0x00000009 ? drdstate: dual role device state this field indicates the state of the usbc. for device mode it should always read 9. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------- 76543210 - - - - drdstate drdstate description 0 a_idle state: this is the start state for a-devices (when the id pin is 0) 1 a_wait_vrise: in this state, the a-device waits for the voltage on vbus to rise above the a- device vbus valid threshold (4.4 v). 2 a_wait_bcon: in this state, the a-device waits for the b-device to signal a connection. 3 a_host: in this state, the a-device th at operates in host mode is operational. 4 a_suspend: the a-device operating as a host is in the suspend mode. 5 a_peripheral: the a-device operates as a peripheral. 6 a_wait_vfall: in this state, the a-device wait s for the voltage on vbus to drop below the a- device session valid threshold (1.4 v). 7 a_vbus_err: in this state, the a-device waits for recovery of the over-current condition that caused it to enter this state. 8 a_wait_discharge: in this state, the a-device waits for the data usb line to discharge (100 us). 9 b_idle: this is the start state fo r b-device (when the id pin is 1). the usbc controller operates in device mode. 10 b_peripheral: in this state, the b-device acts as the peripheral. 11 b_wait_begin_hnp: in this state, the b-device is in suspend mode and waits until 3 ms before initiating the hnp protocol if requested.
382 42023e?sam?07/2013 atsam4l8/l4/l2 12 b_wait_discharge: in this state, the b-device waits for the data usb line to discharge (100 us) before becoming host. 13 b_wait_acon: in this state, the b-device wait s for the a-device to signal a connect before becoming b-host. 14 b_host: in this state, the b-device acts as the host. 15 b_srp_init: in this state, the b-device attempts to start a session using the srp protocol. drdstate description
383 42023e?sam?07/2013 atsam4l8/l4/l2 17.7.1.11 usb descriptor address register name: udesc access type: read-write offset: 0x0830 reset value: - ? udesca: usb descriptor address this field contains the address of the usb descripto r. the three least significant bits are always zero. 31 30 29 28 27 26 25 24 udesca[31:24] 23 22 21 20 19 18 17 16 udesca[23:16] 15 14 13 12 11 10 9 8 udesca[15:8] 76543210 udesca[7:0]
384 42023e?sam?07/2013 atsam4l8/l4/l2 17.7.2 usb device registers 17.7.2.1 device genera l control register register name: udcon access type: read/write offset: 0x0000 reset value: 0x00000100 ? gnak: global nak 0: normal mode. 1: a nak handshake is answered for each usb transaction r egardless of the current endpoint memory bank status. ? ls: low-speed mode force 0: the full-speed mode is active. 1: the low-speed mode is active. this bit can be written to even if usbe is zero or frzclk is one. disabling the usbc (by writing a zero to the usbe bit) does not reset this bit. ? rmwkup: remote wakeup writing a zero to this bit has no effect. writing a one to this bit will send an upstream resume to the host for a remote wakeup. this bit is cleared when the usbc receives a usb reset or once the upstream resume has been sent. ? detach: detach writing a zero to this bit will reconnect the device. writing a one to this bit will physically detach the device (disconnect internal pull-up resistor from dp and dm). ? adden: address enable writing a zero to this bit has no effect. writing a one to this bit will activate the uadd field (usb address). this bit is cleared when a usb reset is received. ? uadd: usb address this field contains the device address. this field is cleared when a usb reset is received. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 ------gnak- 15 14 13 12 11 10 9 8 ---ls--rmwkupdetach 76543210 adden uadd
385 42023e?sam?07/2013 atsam4l8/l4/l2 17.7.2.2 device global interrupt register register name: udint access type: read-only offset: 0x0004 reset value: 0x00000000 note: 1. epnint bits are within th e range from ep0int to ep7int. ? epnint: endpoint n interrupt this bit is cleared when the interrupt source is serviced. this bit is set when an interrupt is triggered by the endpoint n (uestan, ueconn). this triggers a usb interrupt if epninte is one. ? uprsm: upstream resume interrupt this bit is cleared when the udintclr.uprsmc bit is written to one to acknowledge the interrupt (usb clock inputs must be enabled before). this bit is set when the usbc sends a resume signal called ?u pstream resume?. this triggers a usb interrupt if uprsme is one. ? eorsm: end of resume interrupt this bit is cleared when the udintclr.eorsmc bit is written to one to acknowledge the interrupt. this bit is set when the usbc detects a valid ?end of resume? signal initiated by the host. this triggers a usb interrupt if eorsme is one. ? wakeup: wakeup interrupt this bit is cleared when the udintclr.wakeupc bit is written to one to acknowledge the interrupt (usb clock inputs must be enabled before). this bit is set when the usbc is reactiva ted by a filtered non-idle signal from the lines (not by an upstream resume). this triggers an interrupt if wakeupe is one. this interrupt is generated even if the clock is frozen by the frzclk bit. ? eorst: end of reset interrupt this bit is cleared when the udintclr.eorstc bit is written to one to acknowledge the interrupt. this bit is set when a usb ?end of reset? has been dete cted. this triggers a usb interrupt if eorste is one. ? sof: start of frame interrupt this bit is cleared when the udintclr.sofc bit is written to one to acknowledge the interrupt. this bit is set when either a usb ?start of frame? pid (sof) or a low-speed keep-alive has been detected (every 1 ms). this triggers a usb interrupt if sofe is one. the fnum field is updated. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 - - - ep8int (1) ep7int (1) ep6int (1) ep5int (1) ep4int (1) 15 14 13 12 11 10 9 8 ep3int (1) ep2int (1) ep1int (1) ep0int - - - - 76543210 - uprsm eorsm wakeup eorst sof - susp
386 42023e?sam?07/2013 atsam4l8/l4/l2 ? susp: suspend interrupt this bit is cleared when the udintclr.suspc bit is written to one to acknowledge the interrupt. this bit is set when a usb ?suspend? idle bus state has been det ected for 3 frame periods (j stat e for 3 ms). this triggers a usb interrupt if suspe is one.
387 42023e?sam?07/2013 atsam4l8/l4/l2 17.7.2.3 device global interrupt clear register register name: udintclr access type: write-only offset: 0x0008 reset value: 0x00000000 writing a zero to a bit in this register has no effect. writing a one to a bit in this register will clear the corresponding bit in udint. these bits always read as zero. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------- 76543210 - uprsmc eorsmc wakeupc eorstc sofc - suspc
388 42023e?sam?07/2013 atsam4l8/l4/l2 17.7.2.4 device global interrupt set register register name: udintset access type: write-only offset: 0x000c reset value: 0x00000000 writing a zero to a bit in this register has no effect. writing a one to a bit in this register will set the corresponding bit in udint, which may be useful for test or debug purposes . these bits always read as zero. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------- 76543210 - uprsms eorsms wakeups eorsts sofs - susps
389 42023e?sam?07/2013 atsam4l8/l4/l2 17.7.2.5 device global interrupt enable register register name: udinte access type: read-only offset: 0x0010 reset value: 0x00000000 note: 1. epninte bits are within the range from ep0inte to ep7inte. 0: the corresponding interrupt is disabled. 1: the corresponding interrupt is enabled. a bit in this register is cleared when the corresponding bit in udinteclr is written to one. a bit in this register is set when the corresponding bit in udinteset is written to one. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 - - - ep8inte (1) ep7inte (1) ep6inte (1) ep5inte (1) ep4inte (1) 15 14 13 12 11 10 9 8 ep3inte (1) ep2inte (1) ep1inte (1) ep0inte---- 76543210 - uprsme eorsme wakeupe eorste sofe - suspe
390 42023e?sam?07/2013 atsam4l8/l4/l2 17.7.2.6 device global interrupt enable clear register register name: udinteclr access type: write-only offset: 0x0014 reset value: 0x00000000 note: 1. epnintec bits are within th e range from ep0intec to ep7intec. writing a zero to a bit in this register has no effect. writing a one to a bit in this register will clear the corresponding bit in udinte. these bits always read as zero. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 - - - ep8intec (1) ep7intec (1) ep6intec (1) ep5intec (1) ep4intec (1) 15 14 13 12 11 10 9 8 ep3intec (1) ep2intec (1) ep1intec (1) ep0intec - - - - 76543210 - uprsmec eorsmec wakeupec eorstec sofec - suspec
391 42023e?sam?07/2013 atsam4l8/l4/l2 17.7.2.7 device global interrupt enable set register register name: udinteset access type: write-only offset: 0x0018 reset value: 0x00000000 note: 1. epnintes bits are within the range from ep0intes to ep7intes. writing a zero to a bit in this register has no effect. writing a one to a bit in this register will set the corresponding bit in udinte. these bits always read as zero. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 - - - ep8intes (1) ep7intes (1) ep6intes (1) ep5intes (1) ep4intes (1) 15 14 13 12 11 10 9 8 ep3intes (1) ep2intes (1) ep1intes (1) ep0intes - - - - 76543210 - uprsmes eorsmes wakeupes eorstes sofes - suspes
392 42023e?sam?07/2013 atsam4l8/l4/l2 17.7.2.8 endpoint enable/reset register register name: uerst access type: read/write offset: 0x001c reset value: 0x00000000 ? epenn: endpoint n enable note: 1. epenn bits are within th e range from epen0 to epen7. writing a zero to this bit will disable the endpoint n (usb requests will be ignored), and resets the endpoints registers (uecf gn, uestan, ueconn), but not the endpoint confi guration (epbk, epsize, epdir, eptype). writing a one to this bit will enable the endpoint n. 0: the endpoint n is disabled. 1: the endpoint n is enabled. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 - - - - - - - epen8 (1) 76543210 epen7 (1) epen6 (1) epen5 (1) epen4 (1) epen3 (1) epen2 (1) epen1 (1) epen0
393 42023e?sam?07/2013 atsam4l8/l4/l2 17.7.2.9 device frame number register register name: udfnum access type: read-only offset: 0x0020 reset value: 0x00000000 ? fncerr: frame number crc error this bit is cleared upon receiving a usb reset. this bit is set when a corrupted frame number is received. th is bit and the sof interrupt bit are updated at the same time. ? fnum: frame number this field is cleared upon receiving a usb reset. this field contains the 11-bit frame number info rmation, as provided from the last sof packet. fnum is updated even if a corrupted sof is received. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 fncerr - fnum[10:5] 76543210 fnum[4:0] - - -
394 42023e?sam?07/2013 atsam4l8/l4/l2 17.7.2.10 endpoint n configuration register register name: uecfgn, n in [0..7] access type: read/write offset: 0x0100 + (n * 0x04) reset value: 0x00000000 ? repnb: redirected endpoint number this field is used to configure the redirected endpoint number. this field should be zero if the redirected endpoint feature is not used. this field should not be used for control endpoints. this field is cleared upon receiving a usb reset. ? eptype: endpoint type this field selects the endpoint type: this field is cleared upon receiving a usb reset. ? epdir: endpoint direction 0: the endpoint direction is out. 1: the endpoint direction is in (nor for control endpoints). this bit is cleared upon receiving a usb reset. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 ---- repnb 15 14 13 12 11 10 9 8 - - - eptype - - epdir 76543210 - epsize - epbk -- eptype endpoint type 0 0 control 0 1 isochronous 10bulk 1 1 interrupt
395 42023e?sam?07/2013 atsam4l8/l4/l2 ? epsize: endpoint size this field determines the size of each endpoint bank: this field is cleared upon receiving a usb reset (except for the endpoint 0). ? epbk: endpoint banks this bit selects the number of banks for the endpoint: 0: single-bank endpoint 1: double-bank endpoint for control endpoints, a single-bank endpoint shall be selected. this field is cleared upon receiving a usb reset (except for the endpoint 0). epsize endpoint size 0 0 0 8 bytes 00116 bytes 01032 bytes 01164 bytes 1 0 0 128 bytes 1 0 1 256 bytes 1 1 0 512 bytes 1 1 1 1024 bytes
396 42023e?sam?07/2013 atsam4l8/l4/l2 17.7.2.11 endpoint n status register register name: uestan, n in [0..7] access type: read-only 0x0100 offset: 0x0130 + (n * 0x04) reset value: 0x00000000 ? ctrldir: control direction writing a zero or a one to this bit has no effect. this bit is cleared after a setup packet to indicate that the following packet is an out packet. this bit is set after a setup packet to indica te that the following packet is an in packet. ? currbk: current bank this bit is set for non-control endpoints, indicating the current bank: this field may be updated one clock cycle after the rwall bit changes, so the user should not poll this field as an interrupt b it. ? nbusybk: number of busy banks this field is set to indicate the number of busy banks: 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 - - - - - - ctrldir - 15 14 13 12 11 10 9 8 currbk nbusybk ramaceri - dtseq 76543210 - stalledi/ crcerri - nakini nakouti rxstpi/ errorfi rxouti txini currbk current bank 00bank0 01bank1 10reserved 11reserved nbusybk number of busy banks 0 0 0 (all banks free) 011 102 11reserved
397 42023e?sam?07/2013 atsam4l8/l4/l2 for in endpoints, this indicates the number of banks filled by the user and ready for in transfers. when all banks are free an epnint interrupt will be triggered if nbusybke is one. for out endpoints, this indicates the number of banks filled by out transactions from the host. when all banks are busy an epnint interrupt will be triggered if nbusybke is one. ? ramaceri: ram access error interrupt this bit is cleared when the ramaceric bit is written to one, acknowledging the interrupt. this bit is set when a ram access underflow error occurs during an in data stage. ? dtseq: data toggle sequence this field is set to indicate the pid of the current bank: for in transfers, this indicates the data toggle seq uence that will be used for the next packet to be sent. for out transfers, this value indicates the data toggle sequence of the data received in the current bank. ? stalledi: stalled interrupt this bit is cleared when the stalledic bit is written to one, acknowledging the interrupt. this bit is set when a stall handshake has been sent and triggers an epnint interrupt if stallede is one. ? crcerri: crc error interrupt this bit is cleared when the crcerric bit is written to one, acknowledging the interrupt. this bit is set when a crc error has been detected in an isochronous out endpoint bank, and triggers an epnint interrupt if crcerre is one. ? nakini: naked in interrupt this bit is cleared when the nakinic bit is written to one, acknowledging the interrupt. this bit is set when a nak handshake has been sent in response to an in request from the host, and triggers an epnint interrupt if nakine is one. ? nakouti: naked out interrupt this bit is cleared when the nakoutic bit is written to one, acknowledging the interrupt. this bit is set when a nak handshake has been sent in response to an out request from the host, and triggers an epnint interrupt if nakoute is one. ? errorfi: isochronous error flow interrupt this bit is cleared when the errorfic bit is written to one, acknowledging the interrupt. this bit is set, for isochronous in/out endpoints, when an errorflow (underflow or overflow) error occurs, and triggers an epnint interrupt if errorfe is one. an underflow can occur during in stage if the host attempts to read from an empty bank. a zero-length packet is then automatically sent by the usbc. an overflow can also occur during out stage if the host sends a packet while the bank is already full, resulting in the packet being lost. this is typically due to a cpu not being fast enough. this bit is inactive (cleared) for bulk and interrupt in/out endpoints and it means rxstpi for control endpoints. ? rxstpi: received setup interrupt this bit is cleared when the rxstpic bit is written to one, acknowledging the interrupt and freeing the bank. this bit is set, for control endpoints, to signal that the curre nt bank contains a new valid setup packet, and triggers an epni nt interrupt if rxstpe is one. this bit is inactive (cleared) for bulk and interrupt in/out endpoints and it means underfi for isochronous in/out endpoints. ? rxouti: received out data interrupt this bit is cleared when the rxoutic bit is written to one, acknowledging the interrupt. for control endpoints, it releases the bank. for other endpoint types, the user should clear the fifoco n bit to free the bank. rxouti shall always be cleared before clearing fifocon to avoid missing an interrupt. dtseq data toggle sequence 00data0 01data1 1xreserved
398 42023e?sam?07/2013 atsam4l8/l4/l2 this bit is set, for control endpoints, when the current bank c ontains a bulk out packet (data or status stage). this triggers an epnint interrupt if rxoute is one. this bit is set for isochronous, bulk and, interrupt out endpoints, at the same time as fifocon when the current bank is full. this triggers an epnint interrupt if rxoute is one. this bit is inactive (cleared) for isochronous, bulk and interrupt in endpoints. ? txini: transmitted in data interrupt this bit is cleared when the txinic bit is written to one, acknowledging the interrupt. for control endpoints, this will send t he packet. for other endpoint types, the user should clear the fifocon to allow the usbc to send the data. txini shall always be cleared before clearing fifocon to avoid missing an interrupt. this bit is set for control endpoints, when the current bank is ready to accept a new in packet. this triggers an epnint interr upt if txine is one. this bit is set for isochronous, bulk and interrupt in endpoints, at the same time as fifocon when the current bank is free. this triggers an epnint interrupt if txine is one. this bit is inactive (cleared) for isochronous, bulk and interrupt out endpoints.
399 42023e?sam?07/2013 atsam4l8/l4/l2 17.7.2.12 endpoint n status clear register register name: uestanclr, n in [0..7] access type: write-only offset: 0x0160 + (n * 0x04) reset value: 0x00000000 writing a zero to a bit in this register has no effect. writing a one to a bit in this register will clear the corresponding bit in uesta. these bits always read as zero. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 - - - - ramaceric - - - 76543210 - stalledic/ crcerric - nakinic nakoutic rxstpic/ errorfic rxoutic txinic
400 42023e?sam?07/2013 atsam4l8/l4/l2 17.7.2.13 endpoint n status set register register name: uestanset, n in [0..7] access type: write-only offset: 0x0190 + (n * 0x04) reset value: 0x00000000 writing a zero to a bit in this register has no effect. writing a one to a bit in this register will set the corresponding bit in uesta. these bits always read as zero. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 - - - nbusybks ramaceris - - 76543210 - stalledis/ crcerris - nakinis nakoutis rxstpis/ errorfis rxoutis txinis
401 42023e?sam?07/2013 atsam4l8/l4/l2 17.7.2.14 endpoint n control register register name: ueconn, n in [0..7] access type: read-only offset: 0x01c0 + (n * 0x04) reset value: 0x00000000 ? busy0e: busy bank0 enable this bit is cleared when the busy0c bit is written to one. this bit is set when the busy0es bit is wr itten to one. this will set the bank 0 as ?busy?. all transactions, except setup, destined to this bank will be rejected (i.e: nak token will be answered). ? busy1e: busy bank1 enable this bit is cleared when the busy1c bit is written to one. this bit is set when the busy1es bit is wr itten to one. this will set the bank 1 as ?busy?. all transactions, except setup, destined to this bank will be rejected (i.e: nak token will be answered). ? stallrq: stall request this bit is cleared when a new setup packet is received or when the stallrqc bit is written to zero. this bit is set when the stallrqs bit is written to one, requesting a stall handshake to be sent to the host. ? rstdt: reset data toggle the data toggle sequence is cleared when the rstdts bit is written to one (i.e., data0 data toggle sequence will be selected for the next sent (in endpoints) or received (out endpoints) packet. this bit is always read as zero. ? fifocon: fifo control for control endpoints: the fifocon and rwall bits are irrelevant. the software shal l therefore never use them for these endpoints. when read, their value is always 0. for in endpoints: this bit is cleared when the fifoconc bit is written to one, sending the fifo data and switching to the next bank. this bit is set simultaneously to txini, when the current bank is free. for out endpoints: this bit is cleared when the fifoconc bit is written to one, freeing the current bank and switching to the next. this bit is set simultaneously to rxini, when the current bank is full. 31 30 29 28 27 26 25 24 - - - - - - busy1e busy0e 23 22 21 20 19 18 17 16 - - - - stallrq rstdt - - 15 14 13 12 11 10 9 8 - fifocon killbk nbusybke ramacere - - nreply 76543210 - stallede/ crcerre - nakine nakoute rxstpe/ errorfe rxoute txine
402 42023e?sam?07/2013 atsam4l8/l4/l2 ? killbk: kill in bank this bit is cleared by hardware after the completion of the ?kill packet procedure?. this bit is set when the killbks bit is written to one, killing the last written bank. the user shall wait for this bit to be cleared before trying to process another in packet. caution: the bank is cleared when the ?kill packe t? procedure is completed by the usbc core: if the bank is really killed, the nbusybk field is decremented. if the bank sent instead of kill ed (in transfer), the nbusybk field is decremented and the txini flag is se t. this specific cas e can occur if an in token comes while the user tries to kill the bank. note: if two banks are ready to be sent, the above specific case will not occur, since the first bank is sent (in transfer) whi le the last bank is killed. ? nbusybke: number of bu sy banks interrupt enable this bit is cleared when the nbusybkec bit is written to zero, disabling the number of busy banks interrupt (nbusybk). this bit is set when the nbusybkes bi t is written to one, en abling the number of busy banks interrupt (nbusybk). ? ramacere: ramacer interrupt enable this bit is cleared when the ramacerec bit is written to one, disabling the ramacer interrupt (ramaceri). this bit is set when the ramaceres bit is written to one, enabling the ramacer interrupt (ramaceri). ? nreply: no reply this bit is cleared when the nreplyc bit is written to one, disabling the ?no reply? feature, or upon receiving a setup packet. this bit is set when the nreplys bit is written to one, enablin g the ?no_reply? feature. any transaction to this endpoint will be ignored except setup. ? stallede: stalled interrupt enable this bit is cleared when the stalledec bit is writt en to one, disabling the stalled interrupt (stalledi). this bit is set when the stalledes bit is written to one, enabling the stalled interrupt (stalledi). ? crcerre: crc error interrupt enable this bit is cleared when the crcerrec bit is writte n to one, disabling the crc error interrupt (crcerri). this bit is set when the crcerres bit is written to one, enabling the crc error interrupt (crcerri). ? nakine: naked in interrupt enable this bit is cleared when the nakinec bit is writte n to one, disabling the naked in interrupt (nakini). this bit is set when the nakines bit is written to one, enabling the naked in interrupt (nakini). ? nakoute: naked out interrupt enable this bit is cleared when the nakoutec bit is written to one, disabling the naked out interrupt (nakouti). this bit is set when the nakoutes bit is written to one, enabling the naked out interrupt (nakouti). ? rxstpe: received set up interrupt enable this bit is cleared when the rxstpec bit is written to one, disabling the received setup interrupt (rxstpi). this bit is set when the rxstpes bit is written to one, enabling the received setup interrupt (rxstpi). ? errorfe: errorflow interrupt enable this bit is cleared when the errorfec bit is written to one, disabling the underflow interrupt (errorfi). this bit is set when the errorfes bit is written to one, enabling the underflow interrupt (errorfi). ? rxoute: received out data interrupt enable this bit is cleared when the rxoutec bit is written to one, di sabling the received out data interrupt (rxout). this bit is set when the rxoutes bit is written to one, enabling the received out data interrupt (rxout). ? txine: transmitted in data interrupt enable this bit is cleared when the txinec bit is written to one, disabling the tr ansmitted in data interrupt (txini). this bit is set when the txines bit is written to on e, enabling the transmitted in data interrupt (txini).
403 42023e?sam?07/2013 atsam4l8/l4/l2 17.7.2.15 endpoint n control clear register register name: ueconnclr, n in [0..7] access type: write-only offset: 0x0220 + (n * 0x04) reset value: 0x00000000 writing a zero to a bit in this register has no effect. writing a one to a bit in this register will clear the corresponding bit in ueconn. these bits always read as zero. 31 30 29 28 27 26 25 24 - - - - - - busy1ec busy0ec 23 22 21 20 19 18 17 16 - - - - stallrqc - - - 15 14 13 12 11 10 9 8 - fifoconc - nbusybkec ramacerec - - nreplyc 76543210 - stalledec/ crcerrec - nakinec nakoutec rxstpec/ errorfec rxoutec txinec
404 42023e?sam?07/2013 atsam4l8/l4/l2 17.7.2.16 endpoint n control set register register name: ueconnset, n in [0..7] access type: write-only offset: 0x01f0 + (n * 0x04) reset value: 0x00000000 writing a zero to a bit in this register has no effect. writing a one to a bit in this register will set the corresponding bit in ueconn. these bits always read as zero. 31 30 29 28 27 26 25 24 - - - - - - busy1es busy0es 23 22 21 20 19 18 17 16 - - - - stallrqs rstdts - - 15 14 13 12 11 10 9 8 - - killbks nbusybkes ramaceres - - nreplys 76543210 - stalledes/ crcerres - nakines nakoutes rxstpes/ errorfes rxoutes txines
405 42023e?sam?07/2013 atsam4l8/l4/l2 17.7.3 usb host registers 17.7.3.1 host general control register register name: uhcon access type: read/write offset: 0x0400 reset value: 0x00000000 ? ? ? resume: send usb resume writing a zero to this bit has no effect. writing a one to this bit will generate a usb resume on the usb bus. this bit should only be done when the start of frame generation is enabled (sofe bit is one). this bit is cleared when the usb resume has been sent or when a usb reset is requested. ? reset: send usb reset writing a zero to this bit might be useful when a device discon nection is detected (uhint.ddisci is one) while a usb reset is being sent. writing a one to this bit will generate a usb reset on the usb bus. this bit is cleared when the usb reset has been sent. ? sofe: start of frame generation enable writing a zero to this bit will disable the sof generation and to leave the usb bus in idle state. writing a one to this bit will generate sof on the usb bus in full speed mode and keep it alive in low speed mode. this bit is set when a usb reset is requested or an up stream resume interrupt is detected (uhint.rxrsmi). 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 - - - - - resume reset sofe 76543210 --------
406 42023e?sam?07/2013 atsam4l8/l4/l2 17.7.3.2 host global interrupt register register name: uhint access type: read-only offset: 0x0404 reset value: 0x00000000 note: 1. pnint bits are within the range from p0int to p7int. ? pnint: pipe n interrupt this bit is cleared when the interrupt source is served. this bit is set when an interrupt is triggered by the endpoint n (upstan). this triggers a usb interrupt if the corresponding p ipe interrupt enable bit is one (uhinte register). ? hwupi: host wakeup interrupt this bit is cleared when the hwupic bit is written to one. this bit is set when: - the host controller is in the suspend mode (sofe is ze ro) and an upstream resume from the peripheral is detected. - the host controller is in the suspend mode (sof e is zero) and a peripheral disconnection is detected. - the host controller is in the operationnal state (vbusrq is one) and a device connection is detected. this interrupt is generated even if the clock is frozen by the frzclk bit. ? hsofi: host start of frame interrupt this bit is cleared when the hsofic bit is written to one. this bit is set when a sof is issued by the host controller. this triggers a usb interrupt when hsofe is one. when using the host controller in low speed mode, this bit is also set when a keep-alive is sent. ? rxrsmi: upstream resu me received interrupt this bit is set when an upstream resume has been received from the device. this bit is cleared when the rxrsmic is written to one. ? rsmedi: downstream resume sent interrupt this bit is cleared when the rsmedic bit is written to one. this bit set when a downstream resume has been sent to the device. ? rsti: usb reset sent interrupt this bit is cleared when the rstic bit is written to one. this bit is set when a usb reset has been sent to the device. ? ddisci: device disconnection interrupt this bit is cleared when the ddiscic bit is written to one. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------p8int (1) 15 14 13 12 11 10 9 8 p7int (1) p6int (1) p5int (1) p4int (1) p3int (1) p2int (1) p1int (1) p0int 76543210 - hwupi hsofi rxrsmi rsmedi rsti ddisci dconni
407 42023e?sam?07/2013 atsam4l8/l4/l2 this bit is set when the device has been removed from the usb bus. ? dconni: device conn ection in terrupt this bit is cleared when the dconnic bit is written to one. this bit is set when a new device has been connected to the usb bus.
408 42023e?sam?07/2013 atsam4l8/l4/l2 17.7.3.3 host global interrupt clear register register name: uhintclr access type: write-only offset: 0x0408 reset value: 0x00000000 writing a zero to a bit in this register has no effect. writing a one to a bit in this register will clear the corresponding bit in uhint. these bits always read as zero. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------- 76543210 - hwupic hsofic rxrsmic rsme dic rstic ddiscic dconnic
409 42023e?sam?07/2013 atsam4l8/l4/l2 17.7.3.4 host global interrupt set register register name: uhintset access type: write-only offset: 0x040c reset value: 0x00000000 writing a zero to a bit in this register has no effect. writing a one to a bit in this register will set the corresponding bit in uhint. these bits always read as zero. 31 30 29 28 27 26 25 24 ------ - 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------- 76543210 - hwupis hsofis rxrsmis rs medis rstis ddiscis dconnis
410 42023e?sam?07/2013 atsam4l8/l4/l2 17.7.3.5 host global interrupt enable register register name: uhinte access type: read-only offset: 0x0410 reset value: 0x00000000 note: 1. pninte bits are within th e range from p0inte to p7inte. ? pninte: pipe n interrupt enable this bit is cleared when the pnintec bit is written to one. this will disable the pipe n interrupt (pnint). this bit is set when the pnintes bit is written to one. this will enable the pipe n interrupt (pnint). ? hwupie: host wakeup interrupt enable this bit is cleared when the hwupiec bit is written to one. this will disabl e the host wakeup interrupt (hwupi). this bit is set when the hwupies bit is written to one. this will enable the host wakeup interrupt (hwupi). ? hsofie: host start of frame interrupt enable this bit is cleared when the hsofiec bit is written to one. this will disable the host start of frame interrupt (hsofi). this bit is set when the hsofies bit is written to one. this will enable the host start of frame interrupt (hsofi). ? rxrsmie: upstream resume received interrupt enable this bit is cleared when the rxrsmiec bit is written to on e. this will disable the downstream resume interrupt (rxrsmi). this bit is set when the rxrsmies bit is written to one. this will enable the upstream resume received interrupt (rxrsmi). ? rsmedie: downstream resu me sent interrupt enable this bit is cleared when the rsmediec bit is written to on e. this will disable the downstream resume interrupt (rsmedi). this bit is set when the rsmedies bit is written to one. this will enable the downstream resume interrupt (rsmedi). ? rstie: usb reset sent interrupt enable this bit is cleared when the rstiec bit is written to one. this will disable the usb reset sent interrupt (rsti). this bit is set when the rsties bit is written to one. this will enable the usb reset sent interrupt (rsti). ? ddiscie: device discon nection interrupt enable this bit is cleared when the ddisciec bit is written to one. this will disable the device disconnection interrupt (ddisci). this bit is set when the ddiscies bit is written to one. this will enable the device disconnection interrupt (ddisci). ? dconnie: device connection interrupt enable this bit is cleared when the dconniec bit is written to on e. this will disable the device connection interrupt (dconni). this bit is set when the dconnies bit is written to one. th is will enable the device connection interrupt (dconni). 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------p8inte (1) 15 14 13 12 11 10 9 8 p7inte (1) p6inte (1) p5inte (1) p4inte (1) p3inte (1) p2inte (1) p1inte (1) p0inte 76543210 - hwupie hsofie rxrsmie rs medie rstie ddiscie dconnie
411 42023e?sam?07/2013 atsam4l8/l4/l2 17.7.3.6 host global interrupt enable clear register register name: uhinteclr access type: write-only offset: 0x0414 reset value: 0x00000000 note: 1. pnintec bits are within t he range from p0intec to p7intec. writing a zero to a bit in this register has no effect. writing a one to a bit in this register will clear the corresponding bit in uhinte. these bits always read as zero. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------p8intec (1) 15 14 13 12 11 10 9 8 p7intec (1) p6intec (1) p5intec (1) p4intec (1) p3intec (1) p2intec (1) p1intec (1) p0intec 76543210 - hwupiec hsofiec rxrsmiec rsmediec rstiec ddisciec dconniec
412 42023e?sam?07/2013 atsam4l8/l4/l2 17.7.3.7 host global interrupt enable set register register name: uhinteset access type: write-only offset: 0x0418 reset value: 0x00000000 note: 1. pnintes bits are within the range from p0intes to p7intes. writing a zero to a bit in this register has no effect. writing a one to a bit in this register will set the corresponding bit in uhint. these bits always read as zero. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------p8intes (1) 15 14 13 12 11 10 9 8 p7intes (1) p6intes (1) p5intes (1) p4intes (1) p3intes (1) p2intes (1) p1intes (1) p0intes 76543210 - hwupies hsofies rxrsmies rsmedies rsties ddiscies dconnies
413 42023e?sam?07/2013 atsam4l8/l4/l2 17.7.3.8 pipe enable/reset register register name: uprst access type: read/write offset: 0x0041c reset value: 0x00000000 note: 1. penn bits are within the range from pen0 to pen7. ? penn: pipe n enable writing a zero to this bit will disable the pipe n, forcing the pipe to an inactive state and resetting the pipe registers (upc fgn, upstan, and upconn). writing a one to this bit will enable the pipe n. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------pen8 (1) 76543210 pen7 (1) pen6 (1) pen5 (1) pen4 (1) pen3 (1) pen2 (1) pen1 (1) pen0
414 42023e?sam?07/2013 atsam4l8/l4/l2 17.7.3.9 host frame number register register name: uhfnum access type: read/write offset: 0x0420 reset value: 0x00000000 ? flenhigh: frame length this field contains the 8 high-order bits of the 14-bits internal frame counter (frame counter at 12mhz, counter length is 1200 0 to ensure a sof generation every 1 ms). ? fnum: frame number this field contains the current sof number. this field can be written by software to initialize a new frame nu mber value. in this case, at the next sof, the fnum field tak es its new value 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 flenhigh 15 14 13 12 11 10 9 8 - - fnum[10:5] 76543210 fnum[4:0] - - -
415 42023e?sam?07/2013 atsam4l8/l4/l2 17.7.3.10 host start of frame control register register name: uhsofc access type: read/write offset: 0x0424 reset value: 0x00000000 yes during a very short period just before transmitting a start of fram e, this register is locked. thus, after writing, this is recommended to check the register value, and write this register again if necessary. this register is cleared upon sending a usb reset. ? flence: frame length control enable 0:at the beginning of a frame, the internal frame length down-cou nter is loaded to 11999 to ensure a 1 ms frame rate at 12mhz. 0: in full speed mode, the internal frame length down-counter is loaded to 59999 to ensure a 1 ms frame rate at 60mhz. 0: in high speed mode, the internal frame length down-counte r is loaded to 74999 to ensure a 125 us micro-frame rate at 60mhz. 1: at the begining of a frame, the internal frame length down-counter is loaded to the flenc value. ? flenc: frame length control write this field to configure the frame length 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 - ------ flence 15 14 13 12 11 10 9 8 - - flenc[13:0] flenc[15:0] 76543210 flenc[7:0]
416 42023e?sam?07/2013 atsam4l8/l4/l2 17.7.3.11 pipe n configuration register register name: upcfgn, n in [0..7] access type: read/write offset: 0x0500 + (n * 0x04) reset value: 0x00000000 ? binterval: binterval parameter this field corresponds to the bus access period of the pipe. for interrupt pipe, this field corresponds to the desired period from 1 ms to 255 ms. for isochronous pipe, this field corresponds to the desired period calculated as this: 2 (binterval) * 1 ms. for bulk or control pipe, this field corresponds to the desired period from 1 ms to 255 ms. this field is cleared upon sending a usb reset. ? ptype: pipe type this field contains the pipe type. this field is cleared upon sending a usb reset. ? ptoken: pipe token this field contains the endpoint token. 31 30 29 28 27 26 25 24 binterval 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 - - ptype - - ptoken 76543210 - psize - pbk -- ptype pipe type 0 0 control 0 1 isochronous 10bulk 1 1 interrupt ptoken endpoint direction 00 setup 01 in 10 out 11 reserved
417 42023e?sam?07/2013 atsam4l8/l4/l2 ? psize: pipe size this field contains the size of each pipe bank. this field is cleared upon sending a usb reset. ? pbk: pipe banks this bit selects the number of banks for the pipe. 0: single-bank pipe 1: double bank pipe for control endpoints, a single-bank pipe should be selected. this field is cleared upon sending a usb reset. psize endpoint size 0 0 0 8 bytes 00116 bytes 01032 bytes 01164 bytes 1 0 0 128 bytes 1 0 1 256 bytes 1 1 0 512 bytes 1 1 1 1024 bytes
418 42023e?sam?07/2013 atsam4l8/l4/l2 17.7.3.12 pipe n status register register name: upstan, n in [0..7] access type: read-only offset: 0x0530 + (n * 0x04) reset value: 0x00000000 ? currbk: current bank for non-control pipe, this field indicates the number of the current bank. this field may be updated 1 clock cycle after the rwall bit changes, so the user should not poll this field for an interrupt. ? nbusybk: number of busy banks this field indicates the number of busy bank. for out pipe, this field indicates the number of busy bank(s), filled by the user, ready for out transfer. when all banks are busy, this triggers an pnint in terrupt if upconn.nbusybke is one. for in pipe, this field indicates the number of busy bank(s) filled by in transaction from the device. when all banks are free, this triggers an pnint interrup t if upconn.nbusybke is one. ? ramaceri: ram access error interrupt this bit is cleared when the ramaceric bit is written to one. this bit is set when a ram access underflow error occurs during in data stage. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 - currbk nbusybk - ramaceri dtseq 76543210 - rxstalldi/ crcerri errorfi nakedi perri txstpi txouti rxini currbk current bank 00bank0 01bank1 nbusybk number of busy bank 0 0 all banks are free. 0 1 1 busy bank 1 0 2 busy banks 11reserved
419 42023e?sam?07/2013 atsam4l8/l4/l2 ? dtseq: data toggle sequence this field indicates the data pid of the current bank. for out pipes, this field indicates the data toggle of the next packet that will be sent. for in pipes, this field indicates the data toggle of the received packet stored in the current bank. ? rxstalldi: received stalled interrupt this bit is cleared when the rxstalldic bit is written to one. this bit is set, for all endpoints (except isochronous), when a stall handshake has been received on the current bank of the pipe. the pipe is automatically frozen. this triggers an interrupt if the rxstalle bit is one. ? crcerri: crc error interrupt this bit is cleared when the crcerric bit is written to one. this bit is set, for isochronous endpoint, when a crc error occurs on the current bank of the pipe. this triggers an interrupt if the txstpe bit is one. ? errorfi: errorflow interrupt this bit is cleared when the errorfic bit is written to one. this bit is set: - for isochronous and interrupt in/out pipes, when an error flow occurs. this triggers an interrupt if the errorfie bit is one. - for isochronous or interrupt out pipes, when a transaction under flow occurs in the current pipe. i.e, the pipe can?t send the out data packet in time because the current bank is not ready. - for isochronous or interrupt in pipes, when a transaction flow er ror occurs in the current pipe. i.e, the current bank of the pipe is not free when a new in usb packet is received. this packet is not stored in the bank. for interrupt pipes, the overflowed packet is acked to respect the usb standard. ? nakedi: naked interrupt this bit is cleared when the nakedic bit is written to one. this bit is set when a nak has been received on the current bank of the pipe. this trig gers an interrupt if the nakede bit is o ne. ? perri: pipe error interrupt this bit is cleared when the perric bit is written to one. this bit is set when an error occurs on the current bank of t he pipe. this triggers an interrupt if the perre bit is set. refer s to the persta structure of the pipe descriptor ( figure 17-8 ) to determine the source of the error. ? txstpi: transmitted setup interrupt this bit is cleared when the txstpic bit is written to one. this bit is set, for control endpoints, when the current setup bank is free and can be filled. this triggers an interrupt if th e txstpe bit is one. ? txouti: transmitted out data interrupt this bit is cleared when the txoutic bit is written to one. this bit is set when the current out bank is free and can be filled. this triggers an interrupt if the txoute bit is one. ? rxini: received in data interrupt this bit is cleared when the rxinic bit is written to one. this bit is set when a new usb message is stored in the current bank of the pipe. this triggers an interrupt if the rxine bit i s one. dtseq data toggle sequence 00data0 01data1 10reserved 11reserved
420 42023e?sam?07/2013 atsam4l8/l4/l2 17.7.3.13 pipe n status clear register register name: upstanclr, n in [0..7] access type: write-only offset: 0x0560 + (n * 0x04) reset value: 0x00000000 writing a zero to a bit in this register has no effect. writing a one to a bit in this register will clear the corresponding bit in upstan. these bits always read as zero. 31 30 29 28 27 26 25 24 - - ------ 23 22 21 20 19 18 17 16 - - ------ 15 14 13 12 11 10 9 8 - - - - - ramaceric - - 76543210 - rxstalldic/ crcerric errorfic nakedic perric t xstpic txoutic rxinic
421 42023e?sam?07/2013 atsam4l8/l4/l2 17.7.3.14 pipe n status set register register name: upstanset, n in [0..7] access type: write-only offset: 0x0590 + (n * 0x04) reset value: 0x00000000 writing a zero to a bit in this register has no effect. writing a one to a bit in this register will set the corresponding bit in upstan. these bits always read as zero. 31 30 29 28 27 26 25 24 - - ------ 23 22 21 20 19 18 17 16 - - ------ 15 14 13 12 11 10 9 8 - - - - - ramaceris - - 76543210 - rxstalldis/ crcerris errorfic nakedis perri s txstpis txoutis rxinis
422 42023e?sam?07/2013 atsam4l8/l4/l2 17.7.3.15 pipe n control register register name: upconn, n in [0..7] access type: read-only offset: 0x05c0 + (n * 0x04) reset value: 0x00000000 ? initbk: bank initialization this bit is always read as zero. if the user writes a one to the init bkc bit, this will set the current bank to bank0 value for the current pipe. if the user writes a one to the initbks bit, this will set the current bank to bank1 value for the current pipe. this may be useful to restore a pipe to manage alternate pipes on the same physical pipe. ? inittgl: data toggle initialization this bit is always read as zero. if the user writes a one to the inittglc bit, this will set the data toggle to data0 value for the current pipe. if the user writes a one to the inittgls bit, this will set the data toggle to data1 value for the current pipe. this may be useful to restore a pipe to manage alternate pipes on the same physical pipe. ? pfreeze: pipe freeze this bit is cleared when the pfreezec bit is writt en to one. this will enable the pipe request generation. this bit is set when the pfreezes bit is written to one or when the pipe is not configured or when a stall handshake has been received on this pipe, or when inrq in requests have b een processed, or after a pipe enable (uprst.pen rising). this will freeze the pipe requests generation. if the pfreezes bit is written to one while a transaction is on going on the usb bus, the transaction will be properly complete d and then the pfreeze bit will be set. upstan register sh ould be checked to know this last transaction status. ? fifocon: fifo control for out and setup pipes: this bit is cleared when the fifoconc bit is written to one. this will send the fifo data and switch the bank. this bit is set when the current bank is free , at the same time than txouti or txstpi. for in pipes: this bit is cleared when the fifoconc bit is written to one. this will free the current bank and switch to the next bank. this bit is set when a new in message is stored in the current bank, at the same time than rxini. ? nbusybke: number of bu sy banks interrupt enable this bit is cleared when the nbusybkec bit is written to one. this will disable the transmitted in data interrupt (nbusybke). 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 - - - - initbk initdtgl pfreeze - 15 14 13 12 11 10 9 8 - fifocon - nbusybke - ramacere - - 76543210 - rxstallde/ crcerre errorfie nakede perre txstpe txoute rxine
423 42023e?sam?07/2013 atsam4l8/l4/l2 this bit is set when the nbusybkes bit is written to one.this will enable the transmitted in data interrupt (nbusybke). ? ramacere: ram access error interrupt enable this bit is cleared when the nbusybkec bit is written to one. this will disable the transmitted in data interrupt (nbusybke). this bit is set when the nbusybkes bit is written to one.this will enable the transmitted in data interrupt (nbusybke). ? rxstallde: received st alled interrupt enable this bit is cleared when the rxstalldec bit is written to one. this will disable the transmitted in data interrupt (rxstallde). this bit is set when the rxstalldes bit is written to one. this will enable the transmitted in data interrupt (rxstallde). ? crcerre: crc error interrupt enable this bit is cleared when the crcerrec bit is written to one. this will disable the transmitted in data interrupt (crcerre). this bit is set when the crcerres bit is written to one. this will enable the transmitted in data interrupt (crcerre). ? errorfie: errorflow interrupt enable this bit is cleared when the errorfiec bit is written to one. this will disable the transmitted in data interrupt (overfie). this bit is set when the errorfies bit is written to one. this will enable the transmitted in data interrupt (overfie). ? nakede: naked interrupt enable this bit is cleared when the nakedec bit is written to one. this will disable the transmitted in data interrupt (nakede). this bit is set when the nakedes bit is written to one. this will enable the transmitted in data interrupt (nakede). ? perre: pipe error interrupt enable this bit is cleared when the perrec bit is written to one. this will disable the transmitted in data interrupt (perre). this bit is set when the perres bit is written to one. this will enable the transmitted in data interrupt (perre). ? txstpe: transmitted set up interrupt enable this bit is cleared when the txstpec bit is written to one. this will disable the transmitted in data interrupt (txstpe). this bit is set when the txstpes bit is written to one. this will enable the transmitted in data interrupt (txstpe). ? txoute: transmitted out data interrupt enable this bit is cleared when the txoutec bit is written to one. this will disable the transmitted in data interrupt (txoute). this bit is set when the txoutes bit is written to one. this will enable the transmitted in data interrupt (txoute). ? rxine: received in data interrupt enable this bit is cleared when the rxinec bit is written to one. this will disable the transmitted in data interrupt (rxine). this bit is set when the rxines bit is written to one. this will enable the transmitted in data interrupt (rxine).
424 42023e?sam?07/2013 atsam4l8/l4/l2 17.7.3.16 pipe n control set register register name: upconnset, n in [0..7] access type: write-only offset: 0x05f0 + (n * 0x04) reset value: 0x00000000 writing a zero to a bit in this register has no effect. writing a one to a bit in this register will set the corresponding bit in upconn. these bits always read as zero. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 - - - - initbks initdtgls pfreezes - 15 14 13 12 11 10 9 8 --- nbusybkes ---- 76543210 - rxstalldes / crcerres errorfies nakedes perres txstpes txoutes rxines
425 42023e?sam?07/2013 atsam4l8/l4/l2 17.7.3.17 pipe n control clear register register name: upconnclr, n in [0..7] access type: write-only offset: 0x0620 + (n * 0x04) reset value: 0x00000000 writing a zero to a bit in this register has no effect. writing a one to a bit in this register will clear the corresponding bit in upconn. these bits always read as zero. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 - - - - initbkc initdtglc pfreezec - 15 14 13 12 11 10 9 8 - fifoconc - nbusybkec ---- 76543210 - rxstalldec / crcerrec errorfiec nakedec perrec txstpec txoutec rxinec
426 42023e?sam?07/2013 atsam4l8/l4/l2 17.7.3.18 pipe n in request register register name: upinrqn, n in [0..7] access type: read/write offset: 0x0650 + (n * 0x04) reset value: 0x00000001 ? inmode: in request mode writing a zero to this bit will perform a pre-defined nu mber of in requests. this number is the inrq field. writing a one to this bit will allow the usbc to perform infinite in requests when the pipe is not frozen. ? inrq: in request number before freeze this field contains the number of in transactions before th e usbc freezes the pipe. the usbc will perform inrq in requests before freezing the pipe. this counter is automatically decreased by 1 each ti me an in request has been successfully performed. this register has no effect when the inmode bit is 1(infinite in requests generation till the pipe is not frozen). 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------inmode 76543210 inrq
427 42023e?sam?07/2013 atsam4l8/l4/l2 17.8 module configuration the specific configuration for each usbc instance is listed in the following tables. the module bus clocks listed here are connected to the system bus clocks. refer to section 10. ?power man- ager (pm)? on page 108 for details. table 17-10. module clock name pb clock name description clk_usbc_apb clock for the usbc bus interface clk_usbc_ahb clock for the usbc ahb interface cglk the generic clock used for the usbc is gclk7 table 17-11. register reset values register reset value uvers 0x00000310 ufeatures 0x00000007 uaddrsize 0x00001000 uname1 0x48555342 uname2 0x484f5354
428 42023e?sam?07/2013 atsam4l8/l4/l2 18. advanced encrypti on standard (aesa) rev: 1.0.2.0 18.1 features ? compliant with fips publication 197, advanced encryption standard (aes) ? 128-bit cryptographic key ? five confidentiality modes of operation as recommended in nist special publication 800-38a, recommendation for block cipher modes of operation - methods and techniques: ? electronic code book ? cipher block chaining ? cipher feedback ? output feedback ? counter ? short encryption and decrypti on time of 11 clock cycles with 128-bit cryptographic key ? buffering of input and output data for non-stop processing of multiple data blocks ? dma interface for multiple data block processing with minimal cpu intervention ? hardware countermeasures against di fferential power analysis attacks ? 18.2 overview the advanced encryption standard module (aesa) is compliant with the fips (federal infor- mation processing standard) publication 197, advanced encryption standard (aes) , which specifies a symmetric block cipher that is used to encrypt and decrypt electronic data. encryp- tion is the transformation of a usable message, called the plaintext , into an unreadable form, called the ciphertext . on the other hand, decryption is the transformation that recovers the plain- text from the ciphertext. aesa supports 128 bits cr yptographic key size. aesa supports all five confidentiality modes of operation (electronic code book (ecb), cipher book chaining (cbc), cipher feedback (cfb), output feedback (ofb), and counter (ctr)) for symmetric key block cipher algorithms as recommended in the nist (national in stitute of stan- dards and technology) special publication 800-38a, recommendation for block cipher modes of operation - methods and techniques (see section 18.4.2 on page 431 ). for the cfb mode, aesa supports data segment sizes of 8, 16, 32, 64, and 128 bits. aesa requires 11 clock cycles to process one block (128 bits) of input data, where n r is the number of rounds required to process one data block and is 10 when the key size is 128 bits. the relationship between the module?s clock frequency and throughput (in bytes per second) is given by aesa is able to process multiple dat a blocks without stopping. this is due to the buffering of the input and output data within the module, which allows a new data block to be written to and the previous data block to be read from it while the current data block is being processed. aesa is able to interface with a dma controller, thus allowing the processing of multiple data blocks with minimal cpu intervention. two c hannels are supported by the dma interface - one for writing data to aesa and on e for reading data from aesa. clock frequency throughput 16 ------------------------------ ?? ?? 11 () =
429 42023e?sam?07/2013 atsam4l8/l4/l2 finally, aesa supports several hardware counter measures that are useful for protecting data against differential power analysis attacks ( section 18.4.5 on page 433 ). 18.3 product dependencies in order to use this module, other parts of the system must be configured correctly, as described below. 18.3.1 power management if the cpu enters a sleep mode that disables cl ocks used by aesa, the module will stop func- tioning and resume operation after the system wakes up from sleep mode. 18.3.2 clocks the clock (clk_aesa) for aesa?s core operations (such as encryption and decryption) is a generic clock (gclk). it is recommended that aesa be disabl ed before clk_aesa is disabled to avoid freezing the module in an undefined state. 18.3.3 interrupts the aesa interrupt request line is connected to the nvic. using the aesa interrupt requires the nvic to be programmed first. 18.4 functional description 18.4.1 basic programming and operation aesa must be enabled before it can be programmed or used. it is enabled by writing a one to the enable module (enable) bit in the control (ctrl) register. the module is disabled by writ- ing a zero to the same bit. aesa supports both the encryption and decryptio n of data. the desired mode of data process- ing is selected by programming the encryption (encrypt) bit in the mode register. the 128-bit key is wr itten to the four 32-bit key registers. note that access to the key registers is by 32-bit words only (i.e., no halfword or byte access). core high speed bus slave high speed bus dma controller aesa dma controller hardware handshaking interface clk_aesa clk_hsb interrupt controller irq figure 18-1. aesa block diagram
430 42023e?sam?07/2013 atsam4l8/l4/l2 the input data for processing is written to an input buffer consisting of four 32-bit registers through the input data (idata) register address. the input buffer register that is written to when the next write is performed is indicated by the in put data word (idataw) field in the data buffer pointer (databufptr) register. this field is incremented by one or wrapped by hardware when a write to the idata register address is performed. this field can also be programmed, allowing the user direct control ov er which input bu ffer register to write to. note that when aesa is in the cfb operation mode with the data segment size less than 128 bits, the input data must be written to the first (i.e., databu fptr.idataw = 0) and/or second (i.e., databufptr.idataw = 1) input buffer registers (see table 18-1 on page 430 ). once the input data is written to the input buffer, data processing starts automatically. after the content of the input buffer has been transferred out, the input buffer ready (ibufrdy) bit in the status register (sr) is set by hardware (which triggers an interrupt request if the corresponding ibufrdy bit in the interrupt enable register (ier) is programmed to ?1?). this bit is cleared by hardware when new input data is written to the relevant input buffer registers. an initialization vector or an initial counter is required as an input to the encryption and decryp- tion processes for all confidentiality modes of operation, except the ecb operation mode (see section 18.4.2 on page 431 ). the initialization vector or initial counter is wr itten to the four 32-bit initialization vector (initvect) registers. note that access to the initvect registers is by 32- bit words only (i.e., no halfword or byte access). when data processing has completed, the output data ready (odatardy) bit in the sr is set by hardware (which triggers an interrupt reques t if the corresponding odatardy bit in the ier is programmed to ?1?). the processed output data is read out through the output data (odata) register address from the output buffer consisting of four 32-bit registers. the output buffer reg- ister that is read from when the next read is performed is indicated by the output data word (odataw) field in the databufptr register . this field is incremented by one or wrapped by hardware when a read from the odata register address is performed. this field can also be programmed, giving the user direct control over which output buffer register to read from. note that when aesa is in the cfb op eration mode with the data segmen t size less than 128 bits, the output data must be read from the first (i.e., databufptr.odataw = 0) and/or second (i.e., databufptr.odataw = 1) output buffer registers (see table 18-1 on page 430 ). the sr.oda- tardy bit is cleared by hardware after the processed data has been read from the relevant output buffer registers. table 18-1. relevant input/output buffer registers for respective confidentiality modes of operation confidentiality mode of operation rel evant input/output buffer registers ecb all cbc all ofb all 128-bit cfb all 64-bit cfb first and second 32-bit cfb first 16-bit cfb first 8-bit cfb first ctr all
431 42023e?sam?07/2013 atsam4l8/l4/l2 18.4.2 confidentiality modes of operation aesa supports all five confid entiality modes of operat ion as recommended by the nist special publication 800-38a, recommendation for block cipher modes of operation - methods and techniques : ? electronic code book (ecb) ? cipher block chaining (cbc) ? output feedback (ofb) ? cipher feedback (cfb) ? cfb8 (8-bit data segment) ? cfb16 (16-bit data segment) ? cfb32 (32-bit data segment) ? cfb64 (64-bit data segment) ? cfb128 (128-bit data segment) ?ctr: counter the pre-processing, post-processing, and chaining of data required in these modes of operation are automatically perfor med by aesa. for complete informat ion on these mode s of operation, refer to the nist special pub lication 800-38a. the desired mode of operation is selected by programming the operation mode (opmode) field in the mode register. for the cfb mode, the desired data segment size (8, 16, 32, 64, or 128 bits) is selected by programming the cipher feedback data size (cfds) field in the mode register. with the only exception of the ecb operation mode, an initialization vector or an initial counter is required as an input to the encryption and decryp tion processes for all confidentiality modes of operation. the initialization vector or initial counter is stored in the four 32-bit initvect regis- ters. the initialization vector or initial counter is only used for processing the first 128-bit data block of a message. for this reason, it is necessa ry to notify aesa whenever the next data block it is going to process is the beginning of a new message. this is done by writing a one to the new message (newmsg) bit in the ctrl register. the following paragraphs on the selection of the in itialization vector or counter value should be noted to avoid compromising the confidentiality of an operation mode. for the cbc and cfb modes, the initialization vector must be unpredictable (see nist special publication 800-38a , appendix c: generation of initialization vectors for recommendations for generating unpredictable initialization vectors). for the ofb mode, the initialization vector need not be unpredictable, but it must be unique for every message ever encrypted under a given key (see nist special publication 800-38a , appendix c: generation of initialization vectors for recommendations for generating unique ini- tialization vectors). for the ctr mode, the counter value must be unique for each input data block that is ever encrypted under a given key, across all me ssages. in aesa, a counter value for each input data block is automatically generated by applying t he standard incrementing function on a predefined number, m , of lsbs of the counter value (the initial counter value is provided by the user). this number is specified in the module configuration section at the end of this chapter. note that the number of data blocks (128 bits) in the message must be no more than 2 m in order for the coun- ter value to be unique for each input data block within the message . the satisfaction of the
432 42023e?sam?07/2013 atsam4l8/l4/l2 uniquess requirement for counter values across all messages is dependent on the choices of the initial counter values for the messages (see nist special publication 800-38a , appendix b: generation of counter blocks for recommendations for choosing initial couter values). 18.4.3 dma interface aesa is able to interface with a dma controller, thus allowing the processing of multiple data blocks with minimal cpu interv ention. aesa operates in the dma mode when the dma bit in the mode register is programmed to ?1?. two channels are supported by the dma interface - an input data channel for writing input data to aesa and an output data channel for reading output data from aesa. the destination address for the input data channel is the idata register address, whereas the source address for the output data channel is the odata register address. note that the dma write transactions must be performed in the ascending word order, i.e., the first write transaction is for the first word of the input data, the second write transaction is for the second word, and so on. the number of write transactions required depends on the confidential- ity mode of operation that aesa is in and is the same as the number of relevant input buffer registers as shown in table 18-1 on page 430 . likewise, the dma read transactions must also be performed in the ascending word order, i.e., the first read transaction is for the first word of the output data, the second read transaction is for the second word, and so on. 18.4.4 computation of last n k words of expanded key the aes algorithm takes the crypt ographic key provided by the user and pe rforms a key expan- sion routine to generate an expanded key . the expanded key contains a total of 4( n r + 1) 32-bit words, where the first n k (4 for a 128-bit key) words are the user-provided key. for data encryption, the expanded key is used in the forward direction, i.e., the first four words are used in the initial round of data processing, the second four words in the first round, the third four words in the second round, and so on. on the other hand, for data decryption, the expanded key is used in the reverse direction, i.e., the last four words are used in the initial round of data processing, the last second four words in the first round, the last third four words in the second round, and so on. to reduce gate count, aesa does not generate and store the entire expanded key prior to data processing. instead, it computes on-the-fly the round key (four 32-bit words) required for the cur- rent round of data processing. in general, the round key for the current round of data processing can be computed from the n k words of the expanded key generated in the previous rounds. when aesa is operating in the en cryption mode, th e round key for the init ial round of data pro- cessing is simply the us er-provided key writte n to the key registers. on the other hand, when aesa is op erating in the decryption mode, the round key for the initial round of data processing is the last four word s of the expanded key, which is not available unless aesa has performed at least one encryption process prior to operating in the decryption mode. in general, the last n k words of the expanded key must be available before decryption can start. if desired, aesa can be inst ructed to compute the last n k words of the expanded key in advance by writing a one to the decryption key generate (dkeygen) bit in the ctrl register. the com- putation takes n r clock cycles.
433 42023e?sam?07/2013 atsam4l8/l4/l2 alternatively, the last n k words of the expanded key can be automatically computed by aesa when a decryption process is initiated if they have not been computed in advance or have become invalid. note that this will introduce a latency of n r clock cycles to the first decryption process. the last n k words of the expanded key are stored and reused until they are invalidated by one of the following events: ? system reset ? software reset of aesa (by writing a one to the swrst bit in the ctrl register) ? a change to the mode.keysize field ? a write to any of the key registers note that the last n k words of the expanded key is autom atically generated by aesa during an encryption process, so their explicit computati on is not necessary if a decryption process is pre- ceded by an encryption process using the same key. 18.4.5 security features 18.4.5.1 hardware countermeasures agai nst differential power analysis attacks aesa features four types of hardware counte rmeasures that are useful for protecting data against differential power analysis attacks: ? type 1: randomly add one cycle to data processing ? type 2: randomly add one cycle to data processing (other version) ? type 3: add a random number of clock cycles to data processing, subject to a maximum of 11 clock cycles for key size of 128 bits ? type 4: add random spurious power consumption during data processing by default, all countermeasures are enabled. one or more of the countermeasures can be dis- abled by programming the countermeasure type (ctype) field in the mode register. the countermeasures use random numbers generated by a deterministic random number gen- erator embedded in aesa. the seed for the random number generator is written to the drngseed register. note that ac cess to the drngseed register is by 32-bit words only (i.e., no halfword or byte access). note also that a new seed must be written after a change in the key size. note that enabling countermeasures reduces aesa?s throughput. in short, the throughput is highest with all the countermeasures disabled. on the other hand, with all of the countermea- sures enabled, the best protection is achieved but the throughput is worst.
434 42023e?sam?07/2013 atsam4l8/l4/l2 18.5 user interface note: 1. the reset value for this register is device specific. refe r to the module configuration sect ion at the end of this chapt er. table 18-2. aesa register memory map offset register register name access reset 0x00 control register ctrl read/write 0x00000000 0x04 mode register mode read/write 0x000f0000 0x08 data buffer pointer register databufptr read/write 0x00000000 0x0c status register sr read-only 0x00010000 0x10 interrupt enable register ier write-only 0x00000000 0x14 interrupt disable register idr write-only 0x00000000 0x18 interrupt mask register imr read-only 0x00000000 0x20 key register 0 key0 write-only 0x00000000 0x24 key register 1 key1 write-only 0x00000000 0x28 key register 2 key2 write-only 0x00000000 0x2c key register 3 key3 write-only 0x00000000 0x30 key register 4 key4 write-only 0x00000000 0x34 key register 5 key5 write-only 0x00000000 0x38 key register 6 key6 write-only 0x00000000 0x3c key register 7 key7 write-only 0x00000000 0x40 initialization vector register 0 initvect0 write-only 0x00000000 0x44 initialization vector register 1 initvect1 write-only 0x00000000 0x48 initialization vector register 2 initvect2 write-only 0x00000000 0x4c initialization vector register 3 initvect3 write-only 0x00000000 0x50 input data register idata write-only - 0x60 output data register odata read-only - 0x70 drng seed register drngseed write-only 0x00000000 0xf8 parameter register parameter read-only - (1) 0xfc version register version read-only - (1)
435 42023e?sam?07/2013 atsam4l8/l4/l2 18.5.1 control register name: ctrl access type: read/write offset: 0x00 reset value: 0x00000000 ? swrst: software reset writing a one to this bit resets the module. writing a zero to this bit has no effect. ? newmsg: new message writing a one to this bit notifies the module that the next input data block is the beginning of a new message. writing a zero to this bit has no effect. ? dkeygen: decryption key generate writing a one to this bit starts the computation of the last n k words of the expanded key writing a zero to this bit has no effect. ? enable: enable module writing a one to this bit enables the module. writing a zero to this bit disables the module. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------swrst 76543210 - - - - - newmsg dkeygen enable
436 42023e?sam?07/2013 atsam4l8/l4/l2 18.5.2 mode register name: mode access type: read/write offset: 0x04 reset value: 0x000f0000 ? ctype: countermeasure type see section 18.4.5 on page 433 for descriptions of the va rious countermeasure types. all countermeasures are enabled by default. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 ---- ctype 15 14 13 12 11 10 9 8 ----- cfbs 76543210 - opmode dma - - encrypt ctype description x x x 0 countermeasure type 1 is disabled x x x 1 countermeasure type 1 is enabled x x 0 x countermeasure type 2 is disabled x x 1 x countermeasure type 2 is enabled x 0 x x countermeasure type 3 is disabled x 1 x x countermeasure type 3 is enabled 0xxxcountermeasure type 4 is disabled 1xxxcountermeasure type 4 is enabled
437 42023e?sam?07/2013 atsam4l8/l4/l2 ? cfbs: cipher feedback data segment size see nist special publications 800-38a, re commendation for block cipher modes of operation - methods and techniques for information on the cfb mode of operation. see section 18.4.2 on page 431 for information on operating aesa in the cfb mode. ? opmode: confidentiality mode of operation see nist special publications 800-38a, re commendation for block cipher modes of operation - methods and techniques for descriptions of the various confidentiality modes of operation. see section 18.4.2 on page 431 for information on operating aesa in these modes. ? dma: dma mode ? encrypt: encryption cfbs description 0 128 bits 164 bits 232 bits 316 bits 4 8 bits others reserved opmode description 0 electronic code book 1 cipher block chaining 2 cipher feedback 3 output feedback 4 counter others reserved dma description 0 non-dma mode 1 dma mode encrypt description 0decryption 1 encryption
438 42023e?sam?07/2013 atsam4l8/l4/l2 18.5.3 data buffer pointer register name: databufptr access type: read/write offset: 0x08 reset value: 0x00000000 ? odataw: output data word writing to this field changes the value of the output buffer poi nter, which determines which of the four output buffer register s is read from when the next read from t he odata register address is performed. ? idataw: input data word writing to this field changes the value of the input buffer pointer, which determines which of the four input buffer registers is written to when the next write to t he idata register address is performed. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------- 76543210 - - odataw - - idataw
439 42023e?sam?07/2013 atsam4l8/l4/l2 18.5.4 status register name: sr access type: read-only offset: 0x0c reset value: 0x00010000 ? ibufrdy: input buffer ready this bit is set when the input buffer is ready to receive input data. this bit is cleared when the input buffer is not ready to receive input data. ? odatardy: output data ready this bit is set when an encryption or decryption has comp leted and the processed data can be read from the odatan. this bit is cleared when all odatan have been read. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------ibufrdy 15 14 13 12 11 10 9 8 -------- 76543210 -------odatardy
440 42023e?sam?07/2013 atsam4l8/l4/l2 18.5.5 interrupt enable register name: ier access type: write-only offset: 0x10 reset value: 0x00000000 writing a one to a valid bit in this register sets the corresponding bit in the imr. writing a zero to any bit in this register has no effect. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------ibufrdy 15 14 13 12 11 10 9 8 -------- 76543210 -------odatardy
441 42023e?sam?07/2013 atsam4l8/l4/l2 18.5.6 interrupt disable register name: idr access type: write-only offset: 0x14 reset value: 0x00000000 writing a one to a valid bit in this register clears the corresponding bit in the imr. writing a zero to any bit in this register has no effect. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------ibufrdy 15 14 13 12 11 10 9 8 -------- 76543210 -------odatardy
442 42023e?sam?07/2013 atsam4l8/l4/l2 18.5.7 interrupt mask register name: imr access type: read-only offset: 0x18 reset value: 0x00000000 1: the corresponding interrupt is enabled. 0: the corresponding interrupt is disabled. a valid bit in this register is set when a one is written to the corresponding bit in the ier. a valid bit in this register is cleared when a one is written to the corresponding bit in the idr. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------ibufrdy 15 14 13 12 11 10 9 8 -------- 76543210 -------odatardy
443 42023e?sam?07/2013 atsam4l8/l4/l2 18.5.8 key registers name: keyn access type: write-only offset: 0x20 + (n * 0x04) reset value: 0x00000000 ? keyn: key word n this register stores the n th word of the cryptographic key. 31 30 29 28 27 26 25 24 keyn[31:24] 23 22 21 20 19 18 17 16 keyn[23:16] 15 14 13 12 11 10 9 8 keyn[15:8] 76543210 keyn[7:0]
444 42023e?sam?07/2013 atsam4l8/l4/l2 18.5.9 initialization vector registers name: initvectn access type: write-only offset: 0x40 + (n * 0x04) reset value: 0x00000000 ? initvectn: initialization vector word n this register stores the n th word of the initialization vector or counter used by all confidentiality modes of operation, except the ecb operation mode: 31 30 29 28 27 26 25 24 initvectn[31:24] 23 22 21 20 19 18 17 16 initvectn[23:16] 15 14 13 12 11 10 9 8 initvectn[15:8] 76543210 initvectn[7:0] confidentiality mode of operation description cbc, ofb, cfb initialization vector ctr counter ecb not used
445 42023e?sam?07/2013 atsam4l8/l4/l2 18.5.10 input data register name: idata access type: write-only offset: 0x50 reset value: 0x00000000 ? idata: input data a write to this register corresponds to a writ e to one of the four input buffer registers. the input buffer register that is written to is given by the ctrl.idataw field. 31 30 29 28 27 26 25 24 idata[31:24] 23 22 21 20 19 18 17 16 idata[23:16] 15 14 13 12 11 10 9 8 idata[15:8] 76543210 idata[7:0]
446 42023e?sam?07/2013 atsam4l8/l4/l2 18.5.11 output data register name: odata access type: read-only offset: 0x60 reset value: 0x00000000 ? odata: output data a read from this register corresponds to a read from one of the four output buffer registers. the output buffer register that is read from is given by the ctrl.odataw field. 31 30 29 28 27 26 25 24 odata[31:24] 23 22 21 20 19 18 17 16 odata[23:16] 15 14 13 12 11 10 9 8 odata[15:8] 76543210 odata[7:0]
447 42023e?sam?07/2013 atsam4l8/l4/l2 18.5.12 drng seed register name: drng seed access type: write-only offset: 0x70 reset value: 0x00000000 ? seed: drng seed a write to this register corresponds to loading a new seed into the drng. 31 30 29 28 27 26 25 24 seed[31:24] 23 22 21 20 19 18 17 16 seed[23:16] 15 14 13 12 11 10 9 8 seed[15:8] 76543210 seed[7:0]
448 42023e?sam?07/2013 atsam4l8/l4/l2 18.5.13 parameter register name: parameter access type: read-only offset: 0xf8 reset value: - ? ctrmeas: countermeasures ? opmode: maximum number of conf identiality modes of operation ? keysize: maximum key size 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------ctrmeas 76543210 - - - opmode keysize ctrmeas description 0 countermeasures not implemented 1 countermeasures implemented opmode description 0 ecb only 1 ecb and cbc only 2 ecb, cbc, and cfb only 3 ecb, cbc, cfb, and ofb only 4 ecb, cbc, cfb, ofb, and ctr keysize description 0 128-bit only 1 128- and 192-bit only 2 128-, 192-, and 256-bit only
449 42023e?sam?07/2013 atsam4l8/l4/l2 18.5.14 version register name: version access type: read-only offset: 0xfc reset value: - ? variant: variant number this field is reserved. this field is not associat ed with any functionality. ? version: version number this field stores the version number of the module. this field is not associat ed with any functionality. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 ---- variant 15 14 13 12 11 10 9 8 - - - - version[11:8] 76543210 version[7:0]
450 42023e?sam?07/2013 atsam4l8/l4/l2 18.6 module configuration the specific configuration for each aesa instance is listed in the following ta bles. the module bus clocks listed here are connected to the system bus clocks. refer to section 10. ?power man- ager (pm)? on page 108 for details. table 18-3. module configuration feature aesa keysize 128 bit only opmode ecb, cbc, cfb, ofb and ctr countermeasure implemented table 18-4. module clock name clock name description clk_aesa_ahb clock for the aesa ahb interface gclk the generic clock used for the aesa is gclk4 table 18-5. register reset values register reset value version 0x00000102 parameter 0x00000110
451 42023e?sam?07/2013 atsam4l8/l4/l2 19. asynchronous timer (ast) rev: 3.1.1.1 19.1 features ? 32-bit counter with 32-bit prescaler ? clocked source ? system rc oscillator (rcsys) ? 32khz clock (osc32 or rc32) ?apb clock ? generic clock (gclk) ? 1khz clock (osc32 or rc32) ? operation and wakeup during backup ? optional calendar mode supported ? digital prescaler tuning for increased accuracy ? periodic interrup t(s) and peripheral event(s) supported ? alarm interrupt(s) and peripheral event(s) supported ? optional clear on alarm 19.2 overview the asynchronous timer (ast) enables periodi c interrupts and periodic peripheral events, as well as interrupts and peripheral events at a specifi ed time in the future. the ast consists of a 32-bit prescaler which feeds a 32-bit up-counter. the prescaler can be clocked from different clock sources, including the low-power 32khz oscillator, which allows the ast to be used as a real-time timer with a maximum timeout of more than 100 years. also, the pb clock or a generic clock can be used for high-speed operation, a llowing the ast to be used as a general timer. the ast can generate periodic interrupts and peripheral events from output from the prescaler, as well as alarm interrupts and peripheral events, which can trigger at any counter value. addi- tionally, the timer can trigger an overflow interrupt and peripheral event, and be reset on the occurrence of any alarm. this allows periodic interrupts and peripheral events at very long and accurate intervals. to keep track of time during backup mode the ast can run while the core is powered off. this will reduce the power consumption when the system is idle. the ast can also wake up the sys- tem from backup mode using either the alarm wakeup, periodic wakeup. or overflow wakeup mechanisms. the ast has been designed to meet the system tick and real time clock requirements of most embedded operating systems.
452 42023e?sam?07/2013 atsam4l8/l4/l2 19.3 block diagram figure 19-1. asynchronous timer block diagram 19.4 product dependencies in order to use this module, other parts of the system must be configured correctly, as described below. 19.4.1 power management when the ast is enabled, it will re main clocked as long as its sele cted clock source is running. it can also wake the cpu from the currently active sleep mode. refer to section 10. ?power man- ager (pm)? on page 108 for details on the different sleep modes. 19.4.2 clocks the clock for the ast bus interface (clk_ast) is generated by the power manager. this clock is turned on by default, and can be enabled and disabled in the power manager. a number of clocks can be selected as source for the internal presca ler clock clk_ast_prsc. the prescaler, counter, an d interrupt will function as long as this selected clock source is active. the selected clock must be enabled in the system control interface (scif). the following clock sources are available: ? system rc oscillator (rcsys oscilla tor). this oscillator is always enabled, except in some sleep modes. refer to section 42. ?electrical characteristics? on page 1120 for the characteristic frequency of this oscillator. ? 32khz clock (osc32 or rc32). the oscilla tor must be enabled before use. selection between osc32 and rc32 is done inside the backup power manager module. 32-bit prescaler 32-bit counter alarm interrupts counter value clk_ast_cnt ovf control register en cssel psel periodic interrupts alarm register interrupt status and control irqs periodic interval register events wake control wake wake enable register digital tuner register rcsys osc32 apb clock gclk others clk_ast clk_ast_prsc clk_ast clk_ast
453 42023e?sam?07/2013 atsam4l8/l4/l2 ? peripheral bus clock (pb clock). this is the cl ock of the peripheral bus the ast is connected to. ? generic clock (gclk). one of the generic clocks is connected to the ast. this clock must be enabled before use, and remains enabled in sleep modes when the pb clock is active. ? 1khz clock from the 32khz oscillator or 32khz rc oscillator (clk_1k). the oscillator must be enabled before use. selection between osc32 and rc32 is done inside the backup power manager module. in backup mode only the 32khz oscillator and the 32khz rc oscillator are available. the 1khz outputs of those oscillators are also available. refer to section 11. ?backup power manager (bpm)? on page 139 for details. 19.4.3 interrupts the ast interrupt request lines are connected to the nvic. using the ast interrupts requires the nvic to be programmed first. 19.4.4 peripheral events the ast peripheral events are connected via the peripheral event system. refer to section 31. ?peripheral event contro ller (pevc)? on page 844 for details. 19.4.5 debug operation the ast prescaler and counter is not frozen during debug operation when the core is halted, unless the bit corresponding to the ast is set in the peripheral debug register (pdbg). if the ast is configured in a way that requires it to be periodically serviced by the cpu through interrupts or similar, improper operation or data loss may result during debugging. 19.5 functional description 19.5.1 initialization before enabling the ast, the internal ast clock clk_ast_prsc must be enabled, following the procedure specified in section 19.5.1.1 . the clock source select field in the clock register (clock.cssel) selects the source for this clock. the clock en able bit in the clock register (clock.cen) enables the clk_ast_prsc. when clk_ast_prsc is enabled, the ast can be enabled by writing a one to the enable bit in the control register (cr.en). 19.5.1.1 enabling and disabling the ast clock the clock source selection field (clock.cssel ) and the clock enable bit (clock.cen) can- not be changed simultaneously. special procedures must be followed for enabling and disabling the clk_ast_prsc and for changing the source for this clock. to enable clk_ast_prsc: ? write the selected value to clock.cssel ? wait until sr.clkbusy reads as zero ? write a one to clock.cen, without changi ng clock.cssel ? wait until sr.clkbusy reads as zero to disable the clock: ? write a zero to clock.cen to disable the clock, without changing clock.cssel
454 42023e?sam?07/2013 atsam4l8/l4/l2 ? wait until sr.clkbusy reads as zero 19.5.1.2 changing the source clock the clk_ast_prsc must be disabled before swit ching to another source clock. the clock busy bit in the status register (sr.clkbusy) indicates whether the clock is busy or not. this bit is set when the cen bit in the clock register is changed, and cleared when the clock reg- ister can be changed. to change the clock: ? write a zero to clock.cen to disable the clock, without changing clock.cssel ? wait until sr.clkbusy reads as zero ? write the selected value to clock.cssel ? wait until sr.clkbusy reads as zero ? write a one to clock.cen to enable the clock, without changing the clock.cssel ? wait until sr.clkbusy reads as zero 19.5.2 basic operation 19.5.2.1 prescaler when the ast is enabled, the 32-bit pr escaler will increment on the rising edge of clk_ast_prsc. the prescaler value cannot be read or written, but it can be reset by writing a one to the prescaler clear bit in the control register (cr.pclr). the prescaler select field in the control regist er (cr.psel) selects the prescaler bit psel as source clock for the counter (clk_ast_cnt). this results in a counter frequency of: where f prsc is the frequency of the internal prescaler clock clk_ast_prsc. 19.5.2.2 counter operation when enabled, the ast will increment on every 0-to-1 transition of the selected prescaler tap- ping. when the calendar bit in the control regi ster (cr.cal) is zero, the counter operates in counter mode. it will increm ent until it reaches the top value of 0xffffffff, and then wrap to 0x00000000. this sets the status bit overflow in the status register (s r.ovf). optionally, the counter can also be reset when an alarm occurs (see section 19.5.3.2 on page 456 . this will also set the ovf bit. the ast counter value can be read from or written to the counter value (cv) register. note that due to synchronization, continuous reading of the cv register with the lowest prescaler setting will skip every third value. in addition, if clk_ast_prsc is as fast as, or faster than, the clk_ast, the prescaler value must be 3 or higher to be able to read the cv without skipping values. f cnt f prsc 2 psel 1 + ---------------------- - =
455 42023e?sam?07/2013 atsam4l8/l4/l2 19.5.2.3 calendar operation when the cal bit in the control register is one, the counter operates in calendar mode. before this mode is enabled, the prescaler should be set up to give a pulse every second. the date and time can then be read from or written to the calendar value (calv) register. time is reported as seconds, minutes, and hours according to the 24-hour clock format. date is the numeral date of month (starting on 1). month is the numeral month of the year (1 = january, 2 = february, etc.). year is a 6-bit field coun ting the offset from a software-defined leap year (e.g. 2000). the date is automatically compensated for leap years, assuming every year divisible by 4 is a leap year. all peripheral events and interrupts work the same way in calendar mode as in counter mode. however, the alarm register (arn) must be written in time/date format for the alarm to trigger correctly. 19.5.3 interrupts the ast can generate five separate interrupt requests: ?ovf: ovf ? per: per0 ?alarm: alarm0 ? clkready ? ready this allows the user to allocate separate handlers and priorities to the different interrupt types. the generation of the per interrupt is described in section 19.5.3.1 ., and the generation of the alarm interrupt is described in section 19.5.3.2 . the ovf interrupt is generated when the counter overflows, or when the alarm value is re ached, if the clear on alarm bit in the control register is one. the clkready interrupt is generated when sr.clkbusy has a 1-to-0 transi- tion, and indicates that the clock synchroniz ation is completed. the ready interrupt is generated when sr.busy has a 1-to-0 transition, and indicates that the synchronization described in section 19.5.8 is completed. an interrupt request will be generated if the corresponding bit in the interrupt mask register (imr) is set. bits in imr are set by writing a one to the corresponding bit in the interrupt enable register (ier), and cleared by writing a one to the corresponding bit in the interrupt disable register (idr). the interrupt request remains acti ve until the corresponding bit in sr is cleared by writing a one to the corresponding bit in the status clear register (scr). the ast interrupts can wake the cpu from any sleep mode where the source clock and the nvic is active. 19.5.3.1 periodic interrupt the ast can generate periodic interrupts. if the pern bit in the interrupt mask register (imr) is one, the ast will generate an interrup t request on the 0-to-1 transition of the selected bit in the
456 42023e?sam?07/2013 atsam4l8/l4/l2 prescaler when the ast is enabled. the bit is selected by the interval select field in the corre- sponding periodic interval register (pirn.insel), resulting in a periodic interrupt frequency of where f cs is the frequency of the selected clock source. the corresponding pern bit in the status register (sr) will be set when the select ed bit in the prescaler has a 0-to-1 transition. because of synchronizat ion, the transfer of the insel va lue will not happen immediately. when changing/setting the insel value, the user must make sure that the prescaler bit number insel will not have a 0-to-1 transition be fore the insel value is transferr ed to the register. in that case, the first periodic interrupt afte r the change will no t be triggered. 19.5.3.2 alarm interrupt the ast can also generate alar m interrupts. if the al armn bit in imr is one, the ast will gen- erate an interrupt request when the counter val ue matches the selected alarm value, when the ast is enabled. the alarm value is selected by writing the value to the value field in the corre- sponding alarm register (arn.value). the corresponding alarmn bit in sr will be set when the counter reaches the selected alarm value. because of synchronization, the transfer of t he alarm value will not happen immediately. when changing/setting the alarm value, the user must make sure that the counter will not count the selected alarm value before the value is transferred to the register. in that case, the first alarm interrupt after the cha nge will not be triggered. if the clear on alarm bit in the control register (cr.can) is one, the corresponding alarm inter- rupt will clear the count er and set the ovf bit in the stat us register. this will generate an overflow interrupt if the ovf bit in imr is set. 19.5.4 peripheral events the ast can generate a number of peripheral events: ?ovf ? per0 ?alarm0 the pern peripheral event(s) is generated the same way as the per interrupt, as described in section 19.5.3.1 . the alarmn peripheral event(s) is generated the same way as the alarm interrupt, as described in section 19.5.3.2 . the ovf peripheral event is generated the same way as the ovf interrupt, as described in section 19.5.3 - the peripheral event will be genera ted if the corresponding bit in the event mask (evm) register is set. bits in evm register are set by writing a one to the corresponding bit in the event enable f pa f cs 2 insel 1 + ------------------------- =
457 42023e?sam?07/2013 atsam4l8/l4/l2 (eve) register, and cleared by writing a one to the corresponding bit in the event disable (evd) register. 19.5.5 ast wakeup the ast can wake up the system by trigerring a pm interrupt. a wakeup can be generated when the counter overflows, when the counter reaches the selected alarm value, or when the selected prescaler bit has a 0-to-1 transition. this wakeup is propagated to the pm and a pm interrupt is generated if enabled. the ast wakeup is enabled by writing a one to th e corresponding bit in the wake enable regis- ter (wer). when the cpu wakes from sleep, the wake signal must be cleared by writing a one to the corresponding bit in scr to clear the internal wake signal to the sleep controller. if the wake signal is not cleared after waking from sleep, the next sleep instruction will have no effect because the cpu will wake immediatel y after this sl eep instruction. the ast wakeup can wake the cpu from any sleep mode where the source clock is active. the ast wakeup can be configured independently of the interrupt masking. 19.5.6 backup mode if the ast is configured to use a clock that is available in backup mode, the ast can be used to wake up the system from backup. both the alarm wakeup, periodic wakeup, and overflow wakeup mechanisms can be used in this mode. when waking up from backup mode all control re gisters will have the same value as before the backup was entered, except the interrupt mask re gister (imr). imr will be reset with all inter- rupts turned off. the software must first reconfigure the nvic and then enable the interrupts in the ast to again receive interrupts from the ast. the cv register will be updated with the current counter value directly after wakeup from shut- down. the sr will show the status of the ast, including the status bits set during backup operation. when waking up the system from backup the cpu will start executing code from the reset start address. 19.5.7 digital tuner the digital tuner adds th e possibility to compensate for a too-sl ow or a too-fast input clock. the add bit in the digital tuner register (dtr.add) selects if the prescaler frequency should be reduced or increased. if add is ?0?, the prescaler frequency is reduced: where f tuned is the tuned frequency, f 0 is the original prescaler frequency, and value and exp are the corresponding fields to be programmed in dtr. note that dtr.exp must be greater than zero. frequency tuning is disabled by programming dtr.value as zero. f tuned f 0 1 1 roundup 256 value ------------------- - ?? ?? 2 exp () ? 1 + ------------------------------------------------------------------------------- - ? ?? ?? ?? ?? ?? =
458 42023e?sam?07/2013 atsam4l8/l4/l2 if add is ?1?, the prescaler frequency is increased: note that for these formulas to be within an error of 0.01%, it is recommended that the prescaler bit that is used as the clock fo r the counter (selected by cr.psel) or to trigger t he periodic inter- rupt (selected by pirn.insel) be bit 6 or higher. 19.5.8 synchronization as the prescaler and counter operate asynchronously from the user interface, the ast needs a few clock cycles to synchronize the values written to the cr, cv, scr, wer, eve, evd, pirn, arn, and dtr registers. the busy bit in the status register (sr.busy) indicates that the syn- chronization is ongoing. during this time, writes to these registers will be discarded and reading will return a ze ro value. note that synchronization takes place also if the prescaler is clocked from clk_ast. f tuned f 0 1 1 roundup 256 value ------------------- - ?? ?? 2 exp () ? 1 ? ------------------------------------------------------------------------------- - + ?? ?? ?? ?? ?? =
459 42023e?sam?07/2013 atsam4l8/l4/l2 19.6 user interface note: 1. the reset values are device specific. refer to the module configuration section at the end of this chapter. 2. the number of alarm and periodic interval registers are device specific. refer to the module configuration section at the end of this chapter. table 19-1. ast register memory map offset register register name access reset 0x00 control register cr read/write 0x00000000 0x04 counter value cv read/write 0x00000000 0x08 status register sr read-only 0x00000000 0x0c status clear register scr write-only 0x00000000 0x10 interrupt enable register ier write-only 0x00000000 0x14 interrupt disable register idr write-only 0x00000000 0x18 interrupt mask register imr read-only 0x00000000 0x1c wake enable register wer read/write 0x00000000 0x20 alarm register 0 (2) ar0 read/write 0x00000000 0x24 alarm register 1 (2) ar1 read/write 0x00000000 0x30 periodic interval register 0 (2) pir0 read/write 0x00000000 0x34 periodic interval register 1 (2) pir1 read/write 0x00000000 0x40 clock control register clock read/write 0x00000000 0x44 digital tuner register dtr read/write 0x00000000 0x48 event enable eve write-only 0x00000000 0x4c event disable evd write-only 0x00000000 0x50 event mask evm read-only 0x00000000 0x54 calendar value calv read/write 0x00000000 0xf0 parameter register parameter read-only - (1) 0xfc version register version read-only - (1)
460 42023e?sam?07/2013 atsam4l8/l4/l2 19.6.1 control register name: cr access type: read/write offset: 0x00 reset value: 0x00000000 when the sr.busy bit is set, writes to this register will be discarded and this re gister will read as zero. ? psel: prescaler select selects prescaler bit psel as source clock for the counter. ? can: clear on alarm n 0: the corresponding alarm will not clear the counter. 1: the corresponding alarm will clear the counter. ? cal: calendar mode 0: the ast operates in counter mode. 1: the ast operates in calendar mode. ? pclr: prescaler clear writing a zero to this bit has no effect. writing a one to this bit clears the prescaler. this bit always reads as zero. ? en: enable 0: the ast is disabled. 1: the ast is enabled. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 - - - psel 15 14 13 12 11 10 9 8 ------ca1ca0 76543210 - - - - - cal pclr en
461 42023e?sam?07/2013 atsam4l8/l4/l2 19.6.2 counter value name: cv access type: read/write offset: 0x04 reset value: 0x00000000 when the sr.busy bit is set, writes to this register will be discarded and this re gister will read as zero. ? value: ast value the current value of the ast counter. 31 30 29 28 27 26 25 24 value[31:24] 23 22 21 20 19 18 17 16 value[23:16] 15 14 13 12 11 10 9 8 value[15:8] 76543210 value[7:0]
462 42023e?sam?07/2013 atsam4l8/l4/l2 19.6.3 status register name: sr access type: read-only offset: 0x08 reset value: 0x00000000 ? clkrdy: clock ready this bit is cleared when the corresponding bit in scr is written to one. this bit is set when the sr.clkbusy bit has a 1-to-0 transition. ? clkbusy: clock busy 0: the clock is ready and can be changed. 1: clock.cen has been written and the clock is busy. ? ready: ast ready this bit is cleared when the corresponding bit in scr is written to one. this bit is set when the sr.busy bit has a 1-to-0 transition. ? busy: ast busy 0: the ast accepts writes to cr, cv, scr, wer, eve, evd, arn, pirn, and dtr. 1: the ast is busy and will discard writes to cr, cv, scr, wer, eve, evd, arn, pirn, and dtr. ? pern: periodic n this bit is cleared when the corresponding bit in scr is written to one. this bit is set when the selected bit in the prescaler has a 0-to-1 transition. ? alarmn: alarm n this bit is cleared when the corresponding bit in scr is written to one. this bit is set when the counter reaches the selected alarm value. ? ovf: overflow this bit is cleared when the corresponding bit in scr is written to one. this bit is set when an overflow has occurred. 31 30 29 28 27 26 25 24 - - clkrdy clkbusy - - ready busy 23 22 21 20 19 18 17 16 -------per0 15 14 13 12 11 10 9 8 -------alarm0 76543210 -------ovf
463 42023e?sam?07/2013 atsam4l8/l4/l2 19.6.4 status clear register name: scr access type: write-only offset: 0x0c reset value: 0x00000000 when the sr.busy bit is set, writes to this register will be discarded. writing a zero to a bit in this register has no effect. writing a one to a bit in this register will clear the corresponding bit in sr and the corresponding interrupt request. 31 30 29 28 27 26 25 24 - - clkrdy - - - ready - 23 22 21 20 19 18 17 16 -------per0 15 14 13 12 11 10 9 8 -------alarm0 76543210 -------ovf
464 42023e?sam?07/2013 atsam4l8/l4/l2 19.6.5 interrupt enable register name: ier access type: write-only offset: 0x10 reset value: 0x00000000 writing a zero to a bit in this register has no effect. writing a one to a bit in this register will set the corresponding bit in imr. 31 30 29 28 27 26 25 24 - - clkrdy - - - ready - 23 22 21 20 19 18 17 16 -------per0 15 14 13 12 11 10 9 8 -------alarm0 76543210 -------ovf
465 42023e?sam?07/2013 atsam4l8/l4/l2 19.6.6 interrupt disable register name: idr access type: write-only offset: 0x14 reset value: 0x00000000 writing a zero to a bit in this register has no effect. writing a one to a bit in this register will clear the corresponding bit in imr. 31 30 29 28 27 26 25 24 - - clkrdy - - - ready - 23 22 21 20 19 18 17 16 -------per0 15 14 13 12 11 10 9 8 -------alarm0 76543210 -------ovf
466 42023e?sam?07/2013 atsam4l8/l4/l2 19.6.7 interrupt mask register name: imr access type: read-only offset: 0x18 reset value: 0x00000000 0: the corresponding interrupt is disabled. 1: the corresponding interrupt is enabled. a bit in this register is cleared when the corresponding bit in idr is written to one. a bit in this register is set when the corresponding bit in ier is written to one. 31 30 29 28 27 26 25 24 - - clkrdy - - - ready - 23 22 21 20 19 18 17 16 -------per0 15 14 13 12 11 10 9 8 -------alarm0 76543210 -------ovf
467 42023e?sam?07/2013 atsam4l8/l4/l2 19.6.8 wake enable register name: wer access type: read/write offset: 0x1c reset value: 0x00000000 when the sr.busy bit is set writes to this regist er will be discarded and this register will read as zero. this register enables the wakeup signal from the ast. ? pern: periodic n 0: the cpu will not wake up from sleep mode when the se lected bit in the prescaler has a 0-to-1 transition. 1: the cpu will wake up from sleep mode when the sele cted bit in the prescaler has a 0-to-1 transition. ? alarmn: alarm n 0: the cpu will not wake up from sleep mode when the counter reaches the selected alarm value. 1: the cpu will wake up from sleep mode when the counter reaches the selected alarm value. ? ovf: overflow 0: a counter overflow will not wake up the cpu from sleep mode. 1: a counter overflow will wake up the cpu from sleep mode. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------per0 15 14 13 12 11 10 9 8 -------alarm0 76543210 -------ovf
468 42023e?sam?07/2013 atsam4l8/l4/l2 19.6.9 alarm register 0 name: ar0 access type: read/write offset: 0x20 reset value: 0x00000000 when the sr.busy bit is set writes to this regist er will be discarded and this register will read as zero. ? value: alarm value when the counter reaches this value, an alarm is generated. 31 30 29 28 27 26 25 24 value[31:24] 23 22 21 20 19 18 17 16 value[23:16] 15 14 13 12 11 10 9 8 value[15:8] 76543210 value[7:0]
469 42023e?sam?07/2013 atsam4l8/l4/l2 19.6.10 alarm register 1 name: ar1 access type: read/write offset: 0x24 reset value: 0x00000000 when the sr.busy bit is set writes to this regist er will be discarded and this register will read as zero. ? value: alarm value when the counter reaches this value, an alarm is generated. 31 30 29 28 27 26 25 24 value[31:24] 23 22 21 20 19 18 17 16 value[23:16] 15 14 13 12 11 10 9 8 value[15:8] 76543210 value[7:0]
470 42023e?sam?07/2013 atsam4l8/l4/l2 19.6.11 periodic interval register 0 name: pir0 access type: read/write offset: 0x30 reset value: 0x00000000 when the sr.busy bit is set writes to this regist er will be discarded and this register will read as zero. ? insel: interval select the per0 bit in sr will be set when the insel bit in the prescaler has a 0-to-1 transition. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------- 76543210 - - - insel
471 42023e?sam?07/2013 atsam4l8/l4/l2 19.6.12 periodic interval register 1 name: pir1 access type: read/write offset: 0x34 reset value: 0x00000000 when the sr.busy bit is set writes to this regist er will be discarded and this register will read as zero. ? insel: interval select the per1 bit in sr will be set when the insel bit in the prescaler has a 0-to-1 transition. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------- 76543210 - - - insel
472 42023e?sam?07/2013 atsam4l8/l4/l2 19.6.13 clock control register name: clock access type: read/write offset: 0x40 reset value: 0x00000000 when writing to this register, follow the sequence in section 19.5.1 on page 453 . ? cssel: clock source selection this field defines the clock source clk_ast_prsc for the prescaler: ? cen: clock enable 0: clk_ast_prsc is disabled. 1: clk_ast_prsc is enabled. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 - - - - - cssel 76543210 -------cen table 19-2. clock source selection cssel clock source 0 system rc oscillator (rcsys) 1 32khz oscillator (osc32 or rc32) 2 apb clock 3 generic clock (gclk) 4 1khz clock from 32khz oscillator or 32khz rc oscillator (clk_1k)
473 42023e?sam?07/2013 atsam4l8/l4/l2 19.6.14 digital tuner register name: dtr access type: read/write offset: 0x44 reset value: 0x00000000 when the sr.busy bit is set writes to this regist er will be discarded and this register will read as zero. ? value: 0: the frequency is unchanged. 1-255: the frequency will be adjusted according to the formula below. ? add: 0: the resulting frequency is for . 1: the resulting frequency is for . ? exp: the frequency will be adjusted according to the formula above. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 value 76543210 - - add exp f 01 1 roundup 256 value ------------------- - ?? ?? 2 exp () ? 1 + ------------------------------------------------------------------------------- ? ?? ?? ?? ?? ?? value 0 > f 01 1 roundup 256 value ------------------- - ?? ?? 2 exp () ? 1 ? ------------------------------------------------------------------------------- + ?? ?? ?? ?? ?? value 0 >
474 42023e?sam?07/2013 atsam4l8/l4/l2 19.6.15 event enable register name: eve access type: write-only offset: 0x48 reset value: 0x00000000 when the sr.busy bit is set writes to this regist er will be discarded and this register will read as zero. writing a zero to a bit in this register has no effect. writing a one to a bit in this register will set the corresponding bit in evm. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------per0 15 14 13 12 11 10 9 8 -------alarm0 76543210 -------ovf
475 42023e?sam?07/2013 atsam4l8/l4/l2 19.6.16 event disable register name: evd access type: write-only offset: 0x4c reset value: 0x00000000 when the sr.busy bit is set writes to this regist er will be discarded and this register will read as zero. writing a zero to a bit in this register has no effect. writing a one to a bit in this register will clear the corresponding bit in evm. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------per0 15 14 13 12 11 10 9 8 -------alarm0 76543210 -------ovf
476 42023e?sam?07/2013 atsam4l8/l4/l2 19.6.17 event mask register name: evm access type: read-only offset: 0x50 reset value: 0x00000000 0: the corresponding peripheral event is disabled. 1: the corresponding peripheral event is enabled. this bit is cleared when the corresponding bit in evd is written to one. this bit is set when the corresponding bit in eve is written to one. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------per0 15 14 13 12 11 10 9 8 -------alarm0 76543210 -------ovf
477 42023e?sam?07/2013 atsam4l8/l4/l2 19.6.18 calendar value name: calv access type: read/write offset: 0x54 reset value: 0x00000000 when the sr.busy bit is set writes to this regist er will be discarded and this register will read as zero. ? year: year current year. the year is considered a leap year if year[1:0] = 0. ?month: month 1 = january 2 = february ... 12 = december ?day: day day of month, starting with 1. ? hour: hour hour of day, in 24-hour clock format. legal values are 0 through 23. ? min: minute minutes, 0 through 59. ? sec: second seconds, 0 through 59. 31 30 29 28 27 26 25 24 year month[3:2] 23 22 21 20 19 18 17 16 month[1:0] day hour[4] 15 14 13 12 11 10 9 8 hour[3:0] min[5:2] 76543210 min[1:0] sec
478 42023e?sam?07/2013 atsam4l8/l4/l2 19.6.19 parameter register name: parameter access type: read-only offset: 0xf0 reset value: - this register gives the configuration used in the specific device. also refe r to the module configuration section. ? pernvalue: periodic interval n value periodic interval prescaler n tapping if pirnwa is zero. ? pirnwa: periodic interval n writeable 0: periodic interval n prescaler tapping is a constant value. writes to insel field in pirn register will be discarded. 1: periodic interval n prescaler tapping is chos en by writing to insel field in pirn register. ? numpir: number of periodic comparators 0: one periodic comparator. 1: two periodic comparator. ? numar: number of alarm comparators 0: zero alarm comparators. 1: one alarm comparator. 2: two alarm comparators. ? dtrexpvalue: digital tuner exponent value digital tuner exp onent value if dtexpwa is zero. ? dtrexpwa: digital tuner exponent writeable 0: digital tuner exponent is a constant value. writes to exp field in dtr will be discarded. 1: digital tuner exponent is chos en by writing to exp field in dtr. ? dt: digital tuner 0: digital tuner not implemented. 1: digital tuner implemented. 31 30 29 28 27 26 25 24 - - - per1value 23 22 21 20 19 18 17 16 - - - per0value 15 14 13 12 11 10 9 8 pir1wa pir0wa - numpir - - numar 76543210 - dtexpvalue dtexpwa dt
479 42023e?sam?07/2013 atsam4l8/l4/l2 19.6.20 version register name: version access type: read-only offset: 0xfc reset value: - ? variant: variant number reserved. no functionality associated. ? version: version number version number of the module. no functionality associated. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 ---- variant 15 14 13 12 11 10 9 8 - - - - version[11:8] 76543210 version[7:0]
480 42023e?sam?07/2013 atsam4l8/l4/l2 19.7 module configuration the specific configuration for each ast instance is listed in the following tables.the module bus clocks listed here are connected to the system bus clocks. refer to section 10. ?power manager (pm)? on page 108 for details. table 19-3. ast configuration feature ast number of alarm comparators 1 number of periodic comparators 1 digital tuner on table 19-4. ast clocks clock name description clk_ast clock for the ast bus interface gclk the generic clock used for the ast is gclk2 table 19-5. register reset values register reset value version 0x00000311 parameter 0x00004103
481 42023e?sam?07/2013 atsam4l8/l4/l2 20. watchdog timer (wdt) rev.: 5.0.1.0 20.1 features ? watchdog timer counter with 32-bit counter ? timing window watchdog ? clocked from system rc oscillator or one of the 32 khz oscillator (osc32 or rc32) ? configuration lock ? wdt may be enabled at reset by a fuse 20.2 overview the watchdog timer (wdt) will reset the device unless it is periodically serviced by the soft- ware. this allows the device to recover from a condition that has caused the system to be unstable. the wdt has an internal counte r clocked from the system rc oscillator or one of the 32khz oscillator. the wdt counter must be periodically cleared by software to avoid a watchdog reset. if the wdt timer is not cleared correctly, the device will reset and start executing from the boot vector. if the wdt is configured in inte rrupt mode an interrup t request will be generated on the first tim- eout and a reset on the second timeout if the interrupt has not been cleared. 20.3 block diagram figure 20-1. wdt block diagram 20.4 product dependencies in order to use this module, other parts of the system must be configured correctly, as described below. clk_cnt watchdog detector 32-bit counter watchdog reset 0 1 rcsys osc32k cssel cen sync clk_cnt domain pb clock domain pb wdtclr window, cleared en, mode, psel, tban ctrl clr sr watchdog interrupt
482 42023e?sam?07/2013 atsam4l8/l4/l2 20.4.1 power management when the wdt is enabled, it remains clocked in all sleep modes. it is not possible to enter sleep modes where the source clock of clk_cnt is stopped. attempting to do so will result in the chip entering the lowest sleep mode where the source clock is running, leaving the wdt operational. refer to section 10. ?power manager (pm)? on page 108 for details about sleep modes. after a watchdog reset the wdt bit in the reset cause register (rcause) in the power man- ager will be set. 20.4.2 clocks the clock for the wdt bus interface (clk_wdt) is generated by the power manager. this clock is enabled at reset, and can be disabled in the power manager. it is recommended to dis- able the wdt before disabling the clock, to avoid freezing the wdt in an undefined state. there are two possible clock sources for the watchdog timer clock, clk_cnt: ? system rc oscillator (rcsys): th is oscillator is always enabl ed when selected as clock source for the wdt. refer to section 10. ?power manager (pm)? on page 108 for details about the rcsys and sle ep modes. refer to section 42. ?electrical characteristics? on page 1120 for the characteristic frequency of this oscillator. ? 32 khz crystal oscillator or rc o scillator (osc32 or rc32): this oscillator has to be enabled in the backup system control interface (bscif) before using it as clock source for the wdt. selection between osc32 and rc32 should be done in the backup power manager.the wdt will not be able to detect if this clock is stopped. 20.4.3 interrupt the wdt interrupt request line is connected to the nvic. using the wdt interrupt requires the nvic to be programmed first. 20.4.4 debug operation the wdt counter is not frozen during debug operation, unless the core is halted and the bit cor- responding to the wdt is set in the peripheral debug register (pdbg). if the wdt counter is not frozen during debug operation it will need periodically clearing to avoi d a watchdog reset. 20.4.5 fuses the wdt can be enabled at reset. this is controlled by the wdtauto fuse, see section 20.5.5 for details. refer to the fuse settings section in the flash controller chapter for details about wdtauto and how to program the fuses. 20.5 functional description 20.5.1 basic mode 20.5.1.1 wdt control register access to avoid accidental disabling of the watchdog, the control register (ctrl) must be written twice, first with the key field set to 0x55, t hen 0xaa without changing the other bits. failure to do so will cause the write operat ion to be ignored, an d the value in the ctrl register will not be changed. 20.5.1.2 changing clk_cnt clock source after any reset, except for watchdog reset, clk_cnt will be enabled with rcsys as source.
483 42023e?sam?07/2013 atsam4l8/l4/l2 to change the clock source for clk_cnt the following steps must be taken. note that the wdt should always be disabled before changing the clk_cnt source: 1. write a zero to the clock enable bit in the control register (ctrl.cen), leaving the other bits as they are in the control register. this will stop clk_cnt. 2. read back ctrl until ctrl.cen reads zero. the clock has now been stopped. 3. modify the clock source select bit in ctrl (ctrl.cssel) with your new clock selection and write it to ctrl. 4. write a one to ctrl.cen, leaving the other bi ts as they are in ctrl. this will enable the clock. 5. read back ctrl until ctrl.cen reads one. the clock has now been enabled. 20.5.1.3 configuring the wdt if the mode bit in the control register (ctrl. mode) is zero, the wdt is in basic mode. the time out prescale select (pse l) field in ctrl (ctrl.psel) se lects the wdt timeout period: t timeout = t psel = 2 (psel+1) / f clk_cnt 20.5.1.4 enabling the wdt to enable the wdt write a one to the enable bit in the control register (ctrl.en). due to internal synchronization , it will take some time for the ctrl.en bit to read back as one. 20.5.1.5 clearing the wdt counter the wdt counter must be periodically cleared within t psel to avoid a watchdog reset to be issued, see figure 20-2 on page 484 . if the wdt counter is not cleared within t psel a watchdog reset will be issued at the end of t psel , see figure 20-3 on page 484 . the wdt counter is cleared by writing a one to the watchdog clear bit in the clear register (clr.wdtclr), at any correct write to ctrl, or when the counter reaches t timeout and the device is reset. in basic mode, clr.wdtclr can be written at any time when the wdt counter cleared bit in the status register (sr.cleared) is one. due to internal synchronization, clear- ing the wdt counter takes some time. the sr.cleared bit is cleared when writing to clr.wdtclr and set when the clearing is done. any write to the clr.wdtclr bit while sr.cleared is zero will not clear th e counter. writing to the clr.wdtclr bit has to be done in a particular sequence to be valid. the clear register must be wr itten twice, first by wr iting 0x55 to the clr.key field and clr.wdtclr set to one, then by writing 0xaa to clr.key without ch anging the clr.wdtclr bit. writing to the clear register without the correct sequence has no effect.
484 42023e?sam?07/2013 atsam4l8/l4/l2 figure 20-2. basic mode wdt timing diagram, normal operation figure 20-3. basic mode wdt timing diagram, no clear within t psel 20.5.1.6 watchdog reset a watchdog reset will result in a re set and the code will start execut ing from the boot vector, refer to section 10. ?power manager (pm)? on page 108 for details. if the disable after reset (dar) bit in the ctrl register is zero, the wdt counter will restart counting fr om zero when the watchdog reset is released. if the ctrl.dar bit is one the wdt will be di sabled after a watchdog re set. only the ctrl.en bit will be changed after the watc hdog reset. however, if wdtauto fuse is configured to enable the wdt after a watchdog reset, and the ctrl.fcd bit is zero, writing a one to the ctrl.dar bit will have no effect. 20.5.2 window mode the window mode can protect against tight loops of runaway code. this is obtained by adding a ban period to timeout period. during the ban period clearing the wdt counter is not allowed. t psel timeout write one to clr.wdtclr watchdog reset t=t 0 t psel timeout write one to clr.wdtclr watchdog reset t=t 0
485 42023e?sam?07/2013 atsam4l8/l4/l2 if the wdt mode (mode) bit in the ctrl register is one, the wdt is in window mode. note that the ctrl.mode bit can only be change d when the wdt is di sabled (ctrl.en=0). the psel and time ban prescale select (tban) fields in the ctrl register selects the wdt timeout period t timeout = t tban + t psel = (2 (tban+1) + 2 (psel+1) ) / f clk_cnt where t tban sets the time period when clearing the wdt counter by writing to the clr.wdtclr bit is not allowed. doing so will result in a watc hdog reset, the device w ill receive a reset and the code will start executing form the boot vector, see figure 20-5 on page 486 . the wdt counter will be cleared. writing a one to the clr.wdtclr bit within the t psel period will clear the wdt counter and the counter starts counting from zero (t=t 0 ), entering t tban , see figure 20-4 on page 485 . if the value in the ctrl register is changed , the wdt counter will be cleared without a watch- dog reset, regardless of if the value in the wdt counter and the tban value. if the wdt counter reaches t timeout , the counter will be cleared, the device will receive a reset and the code will start execut ing form the boot vector. figure 20-4. window mode wdt timing diagram t tban t psel timeout write one to clr.wdtclr watchdog reset t=t 0
486 42023e?sam?07/2013 atsam4l8/l4/l2 figure 20-5. window mode wdt timing diagram, clearing within t tban , resulting in watchdog reset. 20.5.3 interrupt mode in interrupt mode, the wdt can generate an interrupt request when the wdt counter times out. interrupt mode is enabled by writing a one to the interrupt mode bit in the ctrl register (ctrl.im). when interrupt mode is enabled, the watchdog interrupt bit in the interrupt status register (isr.wint) is set when the wdt counter times out. an interr upt request will be gener- ated if the watchdog interrupt bit in the interrupt mask register (imr.wint) is set, see figure 20-6 . imr.wint is set by writing a one to the watchdog interrupt bit in the interrupt enable reg- ister (ier.wint), and cleared by writing a one to the watchdog interrupt bit in the interrupt disable register (idr.w int). the interrupt request remains active until isr.wint is cleared by writing a one to wint in the inte rrupt clear register (icr.wint). if the watchdog interrupt is not cleared before the next wdt counter timeout, a wdt reset is generated, see figure 20-7 . note that isr.wint will not be cleared by t he wdt reset. if isr.wint is not cleared manually after a wdt reset, a new wdt reset will be issued on the first wdt counter timeout after the reset. interrupt mode can be enabled in both normal and window mode. t tban t psel timeout write one to clr.wdtclr watchdog reset t=t 0
487 42023e?sam?07/2013 atsam4l8/l4/l2 figure 20-6. interrupt mode wdt timing diagram figure 20-7. interrupt mode wdt timing diagram, not clearing the interrupt. t psel timeout watchdog interrupt watchdog reset t=t 0 t psel timeout c lear interrupt is r .w in t imr.wint t psel timeout watchdog interrupt watchdog reset t=t 0 t psel timeout clear interrupt
488 42023e?sam?07/2013 atsam4l8/l4/l2 20.5.4 disabling the wdt the wdt is disabled by writing a zero to the ctrl.en bit. when disabling the wdt no other bits in the ctrl register should be changed until the ctrl.en bit reads back as zero. if the ctrl.cen bit is written to zero, the ctrl.en bit will never read back as zero if changing the value from one to zero. 20.5.5 flash calibration the wdt can be enabled at rese t. this is controlled by the wdtauto fuse. the wdt will be set in basic mode, rcsys is set as source fo r clk_cnt, and psel will be set to a value giving t psel above 100 ms. refer to the fuse settings chapter for details about wdtauto and how to program the fuses. if the flash calibration done (fcd) bit in the ctrl register is zero at a watchdog reset the flash calibration will be redone, and the ctrl.fcd bi t will be set when the calibration is done. if ctrl.fcd is one at a watchdog reset, the conf iguration of the wdt will not be changed during flash calibration. after any other reset the fl ash calibration will always be done, and the ctrl.fcd bit will be set when the calibration is done. 20.5.6 special considerations care must be taken when selecting the psel/tban va lues so that the time out period is greater than the startup time of the ch ip. otherwise a watchdog reset will reset the chip before any code has been run. this can also be avoided by writ ing the ctrl.dar bit to one when configuring the wdt. if the store final value (sfv) bit in the ctrl register is one, the ctrl register is locked for further write accesses. all writes to the ctrl register will be i gnored. once the ctrl register is locked, it can only be unlocked by a reset (e.g. por, ocd, and wdt). the ctrl.mode bit can only be changed when the wdt is disabled (ctrl.en=0). 20.5.7 interrupts the wdt has one interrupt: ? wint: watchdog interrupt, set if wdt is in interrupt mode and the watchdog timer times out.
489 42023e?sam?07/2013 atsam4l8/l4/l2 20.6 user interface note: 1. the reset value for this register is device specific. refe r to the module configuration sect ion at the end of this chapt er. table 20-1. wdt register memory map offset register register name access reset 0x000 control register ctrl read/write 0x00010080 0x004 clear register clr write-only 0x00000000 0x008 status register sr read-only 0x00000003 0x00c interrupt enable register ier write-only 0x00000000 0x010 interrupt disable register idr write-only 0x00000000 0x014 interrupt mask register imr read-only 0x00000000 0x018 interrupt status register isr read-only 0x00000000 0x01c interrupt clear register icr write-only 0x00000000 0x3fc version register version read-only - (1)
490 42023e?sam?07/2013 atsam4l8/l4/l2 20.6.1 control register name: ctrl access type: read/write offset: 0x000 reset value: 0x00010080 ?key this field must be written twice, first with key value 0x55, t hen 0xaa, for a write operation to be effective. this field alway s reads as zero. ? tban: time ban prescale select counter bit tban is used as watchdog ?banned? time frame. in this time frame clearing the wdt timer is forbidden, otherwise a watchdog reset is generated and the wdt timer is cleared. ? cssel: clock source select 0: select the system rc oscillator (rcsys) as clock source. 1: select the 32khz crystal oscillator (osc32k) as clock source. ? cen: clock enable 0: the wdt clock is disabled. 1: the wdt clock is enabled. ? psel: time out prescale select counter bit psel is used as watchdog timeout period. ? im: interrupt mode 0: interrupt mode is disabled. 1: interrupt mode is enabled. ? fcd: flash calibration done this bit is set after any reset. 0: the flash calibration will be redone after a watchdog reset. 1: the flash calibration will not be redone after a watchdog reset. ? sfv: wdt control register store final value 0: wdt control register is not locked. 1: wdt control register is locked. once locked, the control register can not be re-written, only a reset unlocks the sfv bit. 31 30 29 28 27 26 25 24 key 23 22 21 20 19 18 17 16 - tban cssel cen 15 14 13 12 11 10 9 8 - - - psel 76543210 fcd - - im sfv mode dar en
491 42023e?sam?07/2013 atsam4l8/l4/l2 ?mode: wdt mode 0: the wdt is in basic mode, only psel time is used. 1: the wdt is in window mode. tota l timeout period is now tban+psel. writing to this bit when the wdt is enabled has no effect. ? dar: wdt disable after reset 0: after a watchdog reset, the wdt will still be enabled. 1: after a watchdog reset, the wdt will be disabled. ? en: wdt enable 0: wdt is disabled. 1: wdt is enabled. after writing to this bit the read back value will not change until the wdt is enabled/disabled. this due to internal synchronization.
492 42023e?sam?07/2013 atsam4l8/l4/l2 20.6.2 clear register name: clr access type: write-only offset: 0x004 reset value: 0x00000000 when the watchdog timer is enabled, this register must be periodically written within the window time frame or within the watchdog timeout period, to prevent a watchdog reset. ?key this field must be written twice, first with key value 0x55, then 0xaa, for a write operation to be effective. ? wdtclr: watchdog clear writing a zero to this bit has no effect. writing a one to this bit clears the wdt counter. 31 30 29 28 27 26 25 24 key 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------- 76543210 -------wdtclr
493 42023e?sam?07/2013 atsam4l8/l4/l2 20.6.3 status register name: sr access type: read-only offset: 0x008 reset value: 0x00000003 ? cleared: wdt counter cleared this bit is cleared when writing a one to the clr.wdtclr bit. this bit is set when clearing the wdt counter is done. ? window: within window this bit is cleared when the wdt counter is inside the tban period. this bit is set when the wdt counter is inside the psel period. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------- 76543210 ------clearedwindow
494 42023e?sam?07/2013 atsam4l8/l4/l2 20.6.4 interrupt enable register name: ier access type: write-only offset: 0x00c reset value: 0x00000000 writing a zero to a bit in this register has no effect. writing a one to a bit in this register will set the corresponding bit in imr. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------- 76543210 -----wint--
495 42023e?sam?07/2013 atsam4l8/l4/l2 20.6.5 interrupt disable register name: idr access type: write-only offset: 0x010 reset value: 0x00000000 writing a zero to a bit in this register has no effect. writing a one to a bit in this register will clear the corresponding bit in imr. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------- 76543210 -----wint--
496 42023e?sam?07/2013 atsam4l8/l4/l2 20.6.6 interrupt mask register name: imr access type: read-only offset: 0x014 reset value: 0x00000000 0: the corresponding interrupt is disabled. 1: the corresponding interrupt is enabled. a bit in this register is cleared when the corresponding bit in idr is written to one. a bit in this register is set when the corresponding bit in ier is written to one. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------- 76543210 -----wint--
497 42023e?sam?07/2013 atsam4l8/l4/l2 20.6.7 interrupt status register name: isr access type: read-only offset: 0x018 reset value: 0x00000000 0: the corresponding interrupt is cleared. 1: the corresponding interrupt is pending. this bit is cleared when the corresponding bit in icr is written to one. this bit is set when the corresponding interrupt occurs. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------- 76543210 -----wint--
498 42023e?sam?07/2013 atsam4l8/l4/l2 20.6.8 interrupt clear register name: icr access type: write-only offset: 0x01c reset value: 0x00000000 writing a zero to a bit in this register has no effect. writing a one to a bit in this register will clear the corresponding bit in isr and the corresponding interrupt request. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------- 76543210 -----wint--
499 42023e?sam?07/2013 atsam4l8/l4/l2 20.6.9 version register name: version access type: read-only offset: 0x3fc reset value: - ? variant: variant number reserved. no functionality associated. ? version: version number version number of the module. no functionality associated. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 ---- variant 15 14 13 12 11 10 9 8 - - - - version[11:8] 76543210 version[7:0]
500 42023e?sam?07/2013 atsam4l8/l4/l2 20.7 module configuration the specific configuration for each wdt instance is listed in the following tables.the module bus clocks listed here are connected to the system bus clocks. refer to section 10. ?power manager (pm)? on page 108 for details. table 20-2. wdt clocks clock name description clk_wdt clock for the wdt bus interface table 20-3. register reset values register reset value version 0x00000501
501 42023e?sam?07/2013 atsam4l8/l4/l2 21. external interrupt controller (eic) rev: 3.0.2.0 21.1 features ? dedicated interrupt requ est for each interrupt ? individually maskable interrupts ? interrupt on rising or falling edge ? interrupt on high or low level ? asynchronous interrupts fo r sleep modes without clock ? filtering of interrupt lines ? non-maskable nmi interrupt 21.2 overview the external interrupt controller (eic) allows pins to be configured as external interrupts. each external interrupt has its own interrupt request and can be individually masked. each external interrupt can generate an interrupt on rising or falling edge, or high or low level. every interrupt input has a configurable filter to remove spikes from the interrupt source. every interrupt pin can also be configured to be asynchronous in order to wake up the part from sleep modes where the clk_sync clock has been disabled. a non-maskable interrupt (nmi) is also supported. this has the same properties as the other external interrupts, but is connected to the nmi request of the cpu, enabling it to interrupt any other interrupt mode. 21.3 block diagram figure 21-1. eic block diagram edge/level detector mask irq n extintn nmi intn level mode edge ier idr icr ctrl isr im r filter filter polarity control level mode edge asynchronus detector eic_wake enable en dis ctrl clk_sync wake detect async
502 42023e?sam?07/2013 atsam4l8/l4/l2 21.4 i/o lines description 21.5 product dependencies in order to use this module, other parts of the system must be configured correctly, as described below. 21.5.1 i/o lines the external interrupt pins (extintn and nmi) may be multiplexed with i/o controller lines. the programmer must first program the i/o controller to assign the desired eic pins to their periph- eral function. if i/o lines of the eic are not used by the application, they can be used for other purposes by the i/o controller. it is only required to enable the eic inputs actually in use. if an application requires two external interrupts, then only two i/o lines will be a ssigned to eic inputs. 21.5.2 power management all interrupts are available in all sleep modes as long as the eic module is powered. however, in sleep modes where clk_sync is stopped, the interrupt must be configured to asynchronous mode. 21.5.3 clocks the clock for the eic bus interface (clk_eic) is generated by the power manager. this clock is enabled at reset, and can be disabled in the power manager. the filter and synchronous edge/level detector runs on a clock which is stopped in any of the sleep modes where the system rc osc illator (rcsys) is not running. this clock is referred to as clk_sync. 21.5.4 interrupts the external interrupt request lines are connect ed to the nvic. using the external interrupts requires the nvic to be programmed first. using the non-maskable interrupt does not require the nvic to be programmed. 21.5.5 debug operation when an external debugger forces the cpu into debug mode, the eic continues normal opera- tion. if the eic is configured in a way that r equires it to be periodically serviced by the cpu through interrupts or similar, improper operation or data loss may result during debugging. 21.6 functional description 21.6.1 external interrupts the external interrupts are not enabled by default, allowing the proper interrupt vectors to be set up by the cpu before the interrupts are enabled. table 21-1. i/o lines description pin name pin description type nmi non-maskable interrupt input extintn external interrupt input
503 42023e?sam?07/2013 atsam4l8/l4/l2 each external interrupt intn can be configured to prod uce an interrup t on rising or falling edge, or high or low level. external interrupts ar e configured by the mode, edge, and level regis- ters. each interrupt has a bit intn in each of these registers. writing a zero to the intn bit in the mode register enables edge triggered interrupts, while writing a one to the bit enables level trig- gered interrupts. if intn is configured as an edge triggered interrupt, writing a zero to the intn bit in the edge register will cause the interrupt to be triggered on a falling edg e on extintn, while writing a one to the bit will cause the in terrupt to be triggered on a rising edge on extintn. if intn is configured as a leve l triggered interrupt, writing a zero to the intn bit in the level register will cause the interrupt to be triggered on a low level on extintn, while writing a one to the bit will cause the interrupt to be triggered on a high level on extintn. each interrupt has a corresponding bit in each of the interrupt control and status registers. writ- ing a one to the intn bit in the interrupt enabl e register (ier) enables the external interrupt from pin extintn to propagate from the eic to the nvic, while writing a one to intn bit in the interrupt disable register (idr) disables this propagation. the interrupt mask register (imr) can be read to check which interrupts are enabled. when an interrupt triggers, the correspond- ing bit in the interrupt status r egister (isr) will be set. this bit remains set until a one is written to the corresponding bit in the interrupt clear register (icr) or the interrupt is disabled. writing a one to the intn bit in the enable regist er (en) enables the external interrupt on pin extintn, while writing a one to intn bit in the disable register (dis) disables the external inter- rupt. the control register (ctrl) can be read to check which interrupts are enabled. if a bit in the ctrl register is set, but the corresponding bit in imr is not set, an interrupt will not propa- gate to the nvic. however, t he corresponding bit in isr will be set, and eic_wake will be set. note that an external interrupt should not be enabled before it has been configured correctly. if the ctrl.intn bit is zero, the corresponding bi t in isr will always be ze ro. disabling an exter- nal interrupt by writing a one to the dis.intn bit will clear the corresponding bit in isr. refer to the module configuration section for the number of external interrupts. 21.6.2 synchronization and filt ering of external interrupts in synchronous mode the pin value of the extintn pin is synchronized to clk_sync, so spikes shorter than one clk_sync cycle are not guaranteed to produce an interrupt. the syn- chronization of the extintn to clk_sync will delay the propagation of the interrupt to the nvic by two cycles of clk_sync, see figure 21-2 and figure 21-3 for examples (filter off). it is also possible to apply a filter on extintn by writing a one to the intn bit in the filter reg- ister. this filter is a majority voter, if the condition for an interrupt is true for more than one of the latest three cycles of clk_sync the interrup t will be set. this will additionally delay the propa- gation of the interrupt to the nvic by one or two cycles of clk_sync, see figure 21-2 and figure 21-3 for examples (filter on).
504 42023e?sam?07/2013 atsam4l8/l4/l2 figure 21-2. timing diagram, synchronous interr upts, high level or rising edge figure 21-3. timing diagram, synchrono us interrupts, low level or falling edge 21.6.3 non-maskable interrupt the nmi supports the same features as the external interrupts, and is accessed through the same registers. th e description in section 21.6.1 should be followed, accessing the nmi bit instead of the intn bits. the nmi is non-maskable within the cpu in the sense that it can interrupt any other execution mode. still, as for the other exte rnal interrupts, the actual nmi input can be enabled an d disabled by accessing the registers in the eic. 21.6.4 asynchronous interrupts each external inte rrupt can be made asynchronous by wr iting a one to intn in the async reg- ister. this will route the interrupt signal through the asynchronous path of the module. all edge interrupts will be interpreted as leve l interrupts and the f ilter is disabled. if an interrupt is config- ured as edge triggered interr upt in asynchronous mode, a zero in edge.intn will be interpreted as low level, and a one in edge.intn will be inte rpreted as high level. eic_wake will be set immediately after the source triggers the interrupt, while the correspond- ing bit in isr and the interrupt to the nvic will be set on the next rising edge of clk_sync. refer to figure 21-4 on page 505 for details. extintn/nmi clk_sync isr.intn: filter off isr.intn: filter on extintn/nmi clk_sync isr.intn: filter off isr.intn: filter on
505 42023e?sam?07/2013 atsam4l8/l4/l2 when clk_sync is stopped only asynchronous interrupts remain active, and any short spike on this interrupt will wake up the device . eic_wake will restart clk_sync and isr will be updated on the first rising edge of clk_sync. figure 21-4. timing diagram, asynchronous interrupts 21.6.5 wakeup the external interrupts can be used to wake up the part from power save modes if the corre- sponding bit in imr is one. extintn/nmi clk_sync is r .in tn: rising edge or high level eic_wake: rising edge or high level extintn/nmi clk_sync is r .in tn: rising edge or high level eic_wake: rising edge or high level
506 42023e?sam?07/2013 atsam4l8/l4/l2 21.7 user interface note: 1. the reset value is device specific. refer to the m odule configuration section at the end of this chapter. table 21-2. eic register memory map offset register register name access reset 0x000 interrupt enable register ier write-only 0x00000000 0x004 interrupt disable register idr write-only 0x00000000 0x008 interrupt mask register imr read-only 0x00000000 0x00c interrupt status register isr read-only 0x00000000 0x010 interrupt clear register icr write-only 0x00000000 0x014 mode register mode read/write 0x00000000 0x018 edge register edge read/write 0x00000000 0x01c level register level read/write 0x00000000 0x020 filter register filter read/write 0x00000000 0x024 test register test read/write 0x00000000 0x028 asynchronous register async read/write 0x00000000 0x030 enable register en write-only 0x00000000 0x034 disable register dis write-only 0x00000000 0x038 control register ctrl read-only 0x00000000 0x3fc version register version read-only - (1)
507 42023e?sam?07/2013 atsam4l8/l4/l2 21.7.1 interrupt enable register name: ier access type: write-only offset: 0x000 reset value: 0x00000000 ?intn: external interrupt n writing a zero to this bit has no effect. writing a one to this bit will set the corresponding bit in imr. refer to the module configuration section for the number of external interrupts. ? nmi: non-maskable interrupt writing a zero to this bit has no effect. wrting a one to this bit will set the corresponding bit in imr. 31 30 29 28 27 26 25 24 - int30 int29 int28 int27 int26 int25 int24 23 22 21 20 19 18 17 16 int23int22int21int20int19int18int17int16 15 14 13 12 11 10 9 8 int15int14int13int12int11int10 int9 int8 76543210 int7 int6 int5 int4 int3 int2 int1 nmi
508 42023e?sam?07/2013 atsam4l8/l4/l2 21.7.2 interrupt disable register name: idr access type: write-only offset: 0x004 reset value: 0x00000000 ?intn: external interrupt n writing a zero to this bit has no effect. writing a one to this bit will clear the corresponding bit in imr. refer to the module configuration section for the number of external interrupts. ? nmi: non-maskable interrupt writing a zero to this bit has no effect. writing a one to this bit will clear the corresponding bit in imr. 31 30 29 28 27 26 25 24 - int30 int29 int28 int27 int26 int25 int24 23 22 21 20 19 18 17 16 int23int22int21int20int19int18int17int16 15 14 13 12 11 10 9 8 int15int14int13int12int11int10 int9 int8 76543210 int7 int6 int5 int4 int3 int2 int1 nmi
509 42023e?sam?07/2013 atsam4l8/l4/l2 21.7.3 interrupt mask register name: imr access type: read-only offset: 0x008 reset value: 0x00000000 ?intn: external interrupt n 0: the corresponding interrupt is disabled. 1: the corresponding interrupt is enabled. this bit is cleared when the corresponding bit in idr is written to one. this bit is set when the corresponding bit in ier is written to one. refer to the module configuration section for the number of external interrupts. ? nmi: non-maskable interrupt 0: the non-maskable in terrupt is disabled. 1: the non-maskable interrupt is enabled. this bit is cleared when the corresponding bit in idr is written to one. this bit is set when the corresponding bit in ier is written to one. 31 30 29 28 27 26 25 24 - int30 int29 int28 int27 int26 int25 int24 23 22 21 20 19 18 17 16 int23int22int21int20int19int18int17int16 15 14 13 12 11 10 9 8 int15int14int13int12int11int10 int9 int8 76543210 int7 int6 int5 int4 int3 int2 int1 nmi
510 42023e?sam?07/2013 atsam4l8/l4/l2 21.7.4 interrupt status register name: isr access type: read-only offset: 0x00c reset value: 0x00000000 ?intn: external interrupt n 0: an interrupt event has not occurred. 1: an interrupt event has occurred. this bit is cleared by writing a one to the corresponding bit in icr. refer to the module configuration section for the number of external interrupts. ? nmi: non-maskable interrupt 0: an interrupt event has not occurred. 1: an interrupt event has occurred. this bit is cleared by writing a one to the corresponding bit in icr. 31 30 29 28 27 26 25 24 - int30 int29 int28 int27 int26 int25 int24 23 22 21 20 19 18 17 16 int23int22int21int20int19int18int17int16 15 14 13 12 11 10 9 8 int15int14int13int12int11int10 int9 int8 76543210 int7 int6 int5 int4 int3 int2 int1 nmi
511 42023e?sam?07/2013 atsam4l8/l4/l2 21.7.5 interrupt clear register name: icr access type: write-only offset: 0x010 reset value: 0x00000000 ?intn: external interrupt n writing a zero to this bit has no effect. writing a one to this bit will clear the corresponding bit in isr. refer to the module configuration section for the number of external interrupts. ? nmi: non-maskable interrupt writing a zero to this bit has no effect. writing a one to this bit will clear the corresponding bit in isr. 31 30 29 28 27 26 25 24 - int30 int29 int28 int27 int26 int25 int24 23 22 21 20 19 18 17 16 int23int22int21int20int19int18int17int16 15 14 13 12 11 10 9 8 int15int14int13int12int11int10 int9 int8 76543210 int7 int6 int5 int4 int3 int2 int1 nmi
512 42023e?sam?07/2013 atsam4l8/l4/l2 21.7.6 mode register name: mode access type: read/write offset: 0x014 reset value: 0x00000000 ?intn: external interrupt n 0: the external interrupt is edge triggered. 1: the external interrupt is level triggered. refer to the module configuration section for the number of external interrupts. ? nmi: non-maskable interrupt 0: the non-maskable interrupt is edge triggered. 1: the non-maskable interrupt is level triggered. 31 30 29 28 27 26 25 24 - int30 int29 int28 int27 int26 int25 int24 23 22 21 20 19 18 17 16 int23int22int21int20int19int18int17int16 15 14 13 12 11 10 9 8 int15int14int13int12int11int10 int9 int8 76543210 int7 int6 int5 int4 int3 int2 int1 nmi
513 42023e?sam?07/2013 atsam4l8/l4/l2 21.7.7 edge register name: edge access type: read/write offset: 0x018 reset value: 0x00000000 ?intn: external interrupt n 0: the external interrupt triggers on falling edge. 1: the external interrupt triggers on rising edge. refer to the module configuration section for the number of external interrupts. ? nmi: non-maskable interrupt 0: the non-maskable interrupt triggers on falling edge. 1: the non-maskable interrupt triggers on rising edge. 31 30 29 28 27 26 25 24 - int30 int29 int28 int27 int26 int25 int24 23 22 21 20 19 18 17 16 int23int22int21int20int19int18int17int16 15 14 13 12 11 10 9 8 int15int14int13int12int11int10 int9 int8 76543210 int7 int6 int5 int4 int3 int2 int1 nmi
514 42023e?sam?07/2013 atsam4l8/l4/l2 21.7.8 level register name: level access type: read/write offset: 0x01c reset value: 0x00000000 ?intn: external interrupt n 0: the external interrupt triggers on low level. 1: the external interrupt triggers on high level. refer to the module configuration section for the number of external interrupts. ? nmi: non-maskable interrupt 0: the non-maskable interrupt triggers on low level. 1: the non-maskable interrupt triggers on high level. 31 30 29 28 27 26 25 24 - int30 int29 int28 int27 int26 int25 int24 23 22 21 20 19 18 17 16 int23int22int21int20int19int18int17int16 15 14 13 12 11 10 9 8 int15int14int13int12int11int10 int9 int8 76543210 int7 int6 int5 int4 int3 int2 int1 nmi
515 42023e?sam?07/2013 atsam4l8/l4/l2 21.7.9 filter register name: filter access type: read/write offset: 0x020 reset value: 0x00000000 ?intn: external interrupt n 0: the external interrupt is not filtered. 1: the external interrupt is filtered. refer to the module configuration section for the number of external interrupts. ? nmi: non-maskable interrupt 0: the non-maskable interrupt is not filtered. 1: the non-maskable interrupt is filtered. 31 30 29 28 27 26 25 24 - int30 int29 int28 int27 int26 int25 int24 23 22 21 20 19 18 17 16 int23int22int21int20int19int18int17int16 15 14 13 12 11 10 9 8 int15int14int13int12int11int10 int9 int8 76543210 int7 int6 int5 int4 int3 int2 int1 nmi
516 42023e?sam?07/2013 atsam4l8/l4/l2 21.7.10 test register name: test access type: read/write offset: 0x024 reset value: 0x00000000 ? testen: test enable 0: this bit disables external interrupt test mode. 1: this bit enables extern al interrupt test mode. ?intn: external interrupt n writing a zero to this bit will set the input value to intn to zero, if test mode is enabled. writing a one to this bit will set the input value to intn to one, if test mode is enabled. refer to the module configuration section for the number of external interrupts. ? nmi: non-maskable interrupt writing a zero to this bit will set the input value to nmi to zero, if test mode is enabled. writing a one to this bit will set the input value to nmi to one, if test mode is enabled. if testen is 1, the value written to this bit will be the value to the interrupt detector and the value on the pad will be igno red. 31 30 29 28 27 26 25 24 testenint30int29int28int27int26int25int24 23 22 21 20 19 18 17 16 int23int22int21int20int19int18int17int16 15 14 13 12 11 10 9 8 int15int14int13int12int11int10 int9 int8 76543210 int7 int6 int5 int4 int3 int2 int1 nmi
517 42023e?sam?07/2013 atsam4l8/l4/l2 21.7.11 asynchronous register name: async access type: read/write offset: 0x028 reset value: 0x00000000 ?intn: external interrupt n 0: the external interrupt is synchronized to clk_sync. 1: the external interrupt is asynchronous. refer to the module configuration section for the number of external interrupts. ? nmi: non-maskable interrupt 0: the non-maskable interrupt is synchronized to clk_sync. 1: the non-maskable interrupt is asynchronous. 31 30 29 28 27 26 25 24 - int30 int29 int28 int27 int26 int25 int24 23 22 21 20 19 18 17 16 int23int22int21int20int19int18int17int16 15 14 13 12 11 10 9 8 int15int14int13int12int11int10 int9 int8 76543210 int7 int6 int5 int4 int3 int2 int1 nmi
518 42023e?sam?07/2013 atsam4l8/l4/l2 21.7.12 enable register name: en access type: write-only offset: 0x030 reset value: 0x00000000 ?intn: external interrupt n writing a zero to this bit has no effect. writing a one to this bit will enable the corresponding external interrupt. refer to the module configuration section for the number of external interrupts. ? nmi: non-maskable interrupt writing a zero to this bit has no effect. writing a one to this bit will enable the non-maskable interrupt. 31 30 29 28 27 26 25 24 - int30 int29 int28 int27 int26 int25 int24 23 22 21 20 19 18 17 16 int23int22int21int20int19int18int17int16 15 14 13 12 11 10 9 8 int15int14int13int12int11int10 int9 int8 76543210 int7 int6 int5 int4 int3 int2 int1 nmi
519 42023e?sam?07/2013 atsam4l8/l4/l2 21.7.13 disable register name: dis access type: write-only offset: 0x034 reset value: 0x00000000 ?intn: external interrupt n writing a zero to this bit has no effect. writing a one to this bit will disable the corresponding external interrupt. refer to the module configuration section for the number of external interrupts. ? nmi: non-maskable interrupt writing a zero to this bit has no effect. writing a one to this bit will disable the non-maskable interrupt. 31 30 29 28 27 26 25 24 - int30 int29 int28 int27 int26 int25 int24 23 22 21 20 19 18 17 16 int23int22int21int20int19int18int17int16 15 14 13 12 11 10 9 8 int15int14int13int12int11int10 int9 int8 76543210 int7 int6 int5 int4 int3 int2 int1 nmi
520 42023e?sam?07/2013 atsam4l8/l4/l2 21.7.14 control register name: ctrl access type: read-only offset: 0x038 reset value: 0x00000000 ?intn: external interrupt n 0: the corresponding external interrupt is disabled. 1: the corresponding external interrupt is enabled. refer to the module configuration section for the number of external interrupts. ? nmi: non-maskable interrupt 0: the non-maskable in terrupt is disabled. 1: the non-maskable interrupt is enabled. 31 30 29 28 27 26 25 24 - int30 int29 int28 int27 int26 int25 int24 23 22 21 20 19 18 17 16 int23int22int21int20int19int18int17int16 15 14 13 12 11 10 9 8 int15int14int13int12int11int10 int9 int8 76543210 int7 int6 int5 int4 int3 int2 int1 nmi
521 42023e?sam?07/2013 atsam4l8/l4/l2 21.7.15 version register name: version access type: read-only offset: 0x3fc reset value: - ? version: version number version number of the module. no functionality associated. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 - - - - version[11:8] 76543210 version[7:0]
522 42023e?sam?07/2013 atsam4l8/l4/l2 21.8 module configuration the specific configuration for each eic instance is listed in the following tables.the module bus clocks listed here are connected to the system bus clocks. refer to section 10. ?power manager (pm)? on page 108 for details. table 21-3. eic configuration feature eic number of external interrupts, including nmi 9 table 21-4. eic clocks clock name description clk_eic clock for the eic bus interface table 21-5. register reset values register reset value version 0x00000302
523 42023e?sam?07/2013 atsam4l8/l4/l2 22. frequency meter (freqm) rev: 3.1.1.1 22.1 features ? accurately measures a clock frequency ? selectable reference clock ? a selectable clock can be measured ? ratio can be measured with 24-bit accuracy 22.2 overview the frequency meter (freqm) can be used to accurately measure the frequency of a clock by comparing it to a known reference clock. 22.3 block diagram figure 22-1. frequency meter block diagram 22.4 product dependencies in order to use this module, other parts of the system must be configured correctly, as described below. 22.4.1 power management the device can enter a sleep mode while a measurement is ongoing. however, make sure that neither clk_msr nor clk_ref is stopped in the actual sleep mode. counter clk_ref clk_msr refsel refnum, start clksel start value timer trigger isr
524 42023e?sam?07/2013 atsam4l8/l4/l2 freqm interrupts can wake up the device from sleep modes when the measurement is done, but only from sleep modes where clk_freqm is running. refer to section 10. ?power man- ager (pm)? on page 108 for details. 22.4.2 clocks the clock for the freqm bus interface (clk_freqm) is generated by the power manager. it is recommended to disable the freqm before disabling the clock, to avoid freezing the freqm ia an undefined state. a set of clocks can be selected as referenc e (clk_ref) and another set of clocks can be selected for measurement (clk_msr). refer to the clksel and refsel tables in the module configuration section for details. 22.4.3 debug operation when an external debugger forces the cpu in to debug mode, the freqm continues normal operation. if the freqm is configured in a way that requires it to be periodically serviced by the cpu through interrupts or similar, improper operation or data loss may result during debugging. 22.4.4 interrupts the freqm interrupt request line is connected to the internal source of the nvic. using the freqm interrupt requires the nvic to be programmed first. 22.5 functional description the freqm accuratly measures the frequency of a clock by comparing the frequency to a known frequency: f clk_msr = (value/refnum)*f clk_ref 22.5.1 reference clock the reference clock selection (refsel) field in the mode register (mode) selects the clock source for clk_ref. the reference clock is enabled by writing a one to the reference clock enable (refcen) bit in the mode register. this clock should have a known frequency. clk_ref needs to be disabled before switching to another clock. the rclkbusy bit in the status register (sr) indicates whether the clock is busy or not. this bit is set when the mode.refcen bit is written. to change clk_ref: ? write a zero to the mode.refcen bit to disable the clock, without changing the other bits/fields in the mode register. ? wait until the sr.rclkbusy bit reads as zero. ? change the mode.refsel field. ? write a one to the mode.refcen bit to enable the clock, without changing the other bits/fields in the mode register. ? wait until the sr.rclkbusy bit reads as zero. to enable clk_ref: ? write the correct value to the mode.refsel field. ? write a one to the mode.refcen to enable the clock, without changing the other bits/fields in the mode register.
525 42023e?sam?07/2013 atsam4l8/l4/l2 ? wait until the sr.rclkbusy bit reads as zero. to disable clk_ref: ? write a zero to the mode.refcen to disable he clock, without changing the other bits/fields in the mode register. ? wait until the sr.rclkbusy bit reads as zero. 22.5.1.1 cautionary note note that if clock selected as source for clk_ref is stopped during a measurement, this will not be detected by the freqm. the busy bit in the status register w ill never be cleared, and the done interrupt will never be triggered. if the clock select ed as soruce for clk_ref is stopped, it will not be po ssible to change the source for th e reference clock as long as the selected source is not running. 22.5.2 measurement in the mode register the clock source sele ction (clksel) field selects clk_msr and the number of reference clock cycles (refnum) fi eld selects the duration of the measurement. the duration is given in number of clk_ref periodes. writing a one to the start bit in the control register (ctrl) starts the measurement. the busy bit in sr is cleared when the measurement is done. the result of the measurement can be read from the value register (value). the frequency of the measured clock clk_msr is then: f clk_msr = (value/refnum)*f clk_ref 22.5.3 interrupts the freqm has two interrupt sources: ? done: a frequency measurement is done ? rclkrdy: the reference clock is ready these will generate an interrupt request if the corresponding bit in the interrupt mask register (imr) is set. the interrupt sources are ored together to form one interrupt request. the freqm will generate an interrupt request if at least one of the bits in the interr upt mask register (imr) is set. bits in imr are set by writing a one to the corresponding bit in the interrupt enable register (ier) and cleared by writing a one to this bit in the interrupt disable register (idr). the interrupt request remains active until the corresponding bit in the interrupt status register (isr) is cleared by writing a one to this bit in the interrupt clear register (icr). because all the interrupt sources are ored t ogether, the interrupt reque st from the freqm will rema in active until all the bits in isr are cleared.
526 42023e?sam?07/2013 atsam4l8/l4/l2 22.6 user interface note: 1. the reset value for this register is device specific. refe r to the module configuration sect ion at the end of this chapt er. table 22-1. freqm register memory map offset register register name access reset 0x000 control register ctrl write-only 0x00000000 0x004 mode register mode read/write 0x00000000 0x008 status register status read-only 0x00000000 0x00c value register value read-only 0x00000000 0x010 interrupt enable register ier write-only 0x00000000 0x014 interrupt disable register idr write-only 0x00000000 0x018 interrupt mask register imr read-only 0x00000000 0x01c interrupt status register isr read-only 0x00000000 0x020 interrupt clear register icr write-only 0x00000000 0x3fc version register version read-only - (1)
527 42023e?sam?07/2013 atsam4l8/l4/l2 22.6.1 control register name: ctrl access type: write-only offset: 0x000 reset value: 0x00000000 ?start writing a zero to this bit has no effect. writing a one to this bit will start a measurement. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------- 76543210 -------start
528 42023e?sam?07/2013 atsam4l8/l4/l2 22.6.2 mode register name: mode access type: read/write offset: 0x004 reset value: 0x00000000 ? refcen: reference clock enable 0: the reference clock is disabled 1: the reference clock is enabled ? clksel: clock source selection selects the source for clk_msr. see table in module configuration chapter for details. ? refnum: number of reference clock cycles selects the duration of a measurement, given in number of clk_ref cycles. ? refsel: reference clock selection selects the source for clk_ref. see table in module configuration chapter for details. 31 30 29 28 27 26 25 24 refcen------- 23 22 21 20 19 18 17 16 - - - clksel 15 14 13 12 11 10 9 8 refnum 76543210 - - - - - refsel
529 42023e?sam?07/2013 atsam4l8/l4/l2 22.6.3 status register name: status access type: read-only offset: 0x008 reset value: 0x00000000 ? rclkbusy: freqm reference clock status 0: the freqm ref clk is ready, so a measurement can start. 1: the freqm ref clk is not ready, so a measurement should not be started. ? busy: freqm status 0: the frequency meter is idle. 1: frequency measurement is on-going. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------- 76543210 ------rclkbusybusy
530 42023e?sam?07/2013 atsam4l8/l4/l2 22.6.4 value register name: value access type: read-only offset: 0x00c reset value: 0x00000000 ? value: result from measurement. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 value[23:16] 15 14 13 12 11 10 9 8 value[15:8] 76543210 value[7:0]
531 42023e?sam?07/2013 atsam4l8/l4/l2 22.6.5 interrupt enable register name: ier access type: write-only offset: 0x010 reset value: 0x00000000 writing a zero to a bit in this register has no effect. writing a one to a bit in this register will set the corresponding bit in imr. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------- 76543210 ------rclkrdydone
532 42023e?sam?07/2013 atsam4l8/l4/l2 22.6.6 interrupt disable register name: idr access type: write-only offset: 0x014 reset value: 0x00000000 writing a zero to a bit in this register has no effect. writing a one to a bit in this register will clear the corresponding bit in imr. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------- 76543210 ------rclkrdydone
533 42023e?sam?07/2013 atsam4l8/l4/l2 22.6.7 interrupt mask register name: imr access type: read-only offset: 0x018 reset value: 0x00000000 0: the corresponding interrupt is disabled. 1: the corresponding interrupt is enabled. a bit in this register is cleared when the corresponding bit in idr is written to one. a bit in this register is set when the corresponding bit in ier is written to one. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------- 76543210 ------rclkrdydone
534 42023e?sam?07/2013 atsam4l8/l4/l2 22.6.8 interrupt status register name: isr access type: read-only offset: 0x01c reset value: 0x00000000 0: the corresponding interrupt is cleared. 1: the corresponding interrupt is pending. a bit in this register is set when the corresponding bit in status has a one to zero transition. a bit in this register is cleared when the corresponding bit in icr is written to one. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------- 76543210 ------rclkrdydone
535 42023e?sam?07/2013 atsam4l8/l4/l2 22.6.9 interrupt clear register name: icr access type: write-only offset: 0x020 reset value: 0x00000000 writing a zero to a bit in this register has no effect. writing a one to a bit in this register will clear the corresponding bit in isr and the corresponding interrupt request. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------- 76543210 ------rclkrdydone
536 42023e?sam?07/2013 atsam4l8/l4/l2 22.6.10 version register name: version access type: read-only offset: 0x3fc reset value: - ? variant: variant number reserved. no functionality associated. ? version: version number version number of the module. no functionality associated. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 ---- variant 15 14 13 12 11 10 9 8 - - - - version[11:8] 76543210 version[7:0]
537 42023e?sam?07/2013 atsam4l8/l4/l2 22.7 module configuration the specific configuration for each freqm instance is listed in the following tables. the module bus clocks listed here are connected to the system bus clocks. refer to section 10. ?power man- ager (pm)? on page 108 for details. table 22-2. freqm clock name clock name description clk_freqm clock for the freqm bus interface clk_msr measured clock clk_ref reference clock table 22-3. register reset values register reset value version 0x00000311 table 22-4. clock sources for clk_msr clksel clock/oscillator description 0 clk_cpu the clock the cpu runs on 1 clk_ahb high speed bus clock 2 clk_apba peripheral bus a clock 3 clk_apbb peripheral bus b clock 4 clk_apbc peripheral bus c clock 5 clk_apbd peripheral bus d clock 6 osc0 output clock from oscillator 0 7 clk32k 32khz output clock from osc32k or rc32k 8 rcsys output clock from rcsys oscillator 9 dfll0 output clock from dfll0 11-22 gclk0-11 generic clock 0 through 11 23 rc80m output clock from rc80m 24 rcfast output clock from rcfast 25 rc1m output clock from vreg rc1m 26 pll output clock from pll0 27-31 reserved
538 42023e?sam?07/2013 atsam4l8/l4/l2 table 22-5. clock sources for clk_ref refsel clock/oscillator description 0 rcsys system rc oscillator clock 1 clk32k 32khz output clock from osc32k or rc32k 2 clk1k 1khz output clock from osc32k or rc32k 3 gclk11 generic clock 11 4-7 reserved
539 42023e?sam?07/2013 atsam4l8/l4/l2 23. general-purpose input/ output controller (gpio) rev: 2.1.5.5 23.1 features ? configurable pin-change, rising-edge, or falling-edge interrupt ? configurable peripheral event generator ? glitch filter providing rejection of pulses shorter than one clock cycle ? input visibility and output control ? multiplexing of peripheral functions on i/o pins ? programmable internal pull-up resistor ? programmable internal pull-down resistor ? programmable output driver strength ? programmable internal input schmitt trigger ? programmable output slew rate ? 23.2 overview the general purpose input/output controller (gpio) controls the i/o pins of the microcontroller. each gpio pin may be used as a general-purpose i/o or be assigned to a function of an embed- ded peripheral. the gpio is configured using the peripheral bus (pb). 23.3 block diagram figure 23-1. gpio block diagram interrupt controller power manager embedded peripheral general purpose input/output - gpio gpio interrupt request clk_gpio pin control signals pin pin pin pin pin mcu i/o pins configuration interface
540 42023e?sam?07/2013 atsam4l8/l4/l2 23.4 i/o lines description 23.5 product dependencies in order to use this module, other parts of the system must be configured correctly, as described below. 23.5.1 power management if the cpu enters a sleep mode that disables cl ocks used by the gpio, the gpio will stop func- tioning and resume operation after the system wakes up from sleep mode. if a peripheral function is configured for a gpio pin, the peripheral will be able to control the gpio pin even if the gpio clock is stopped. 23.5.2 clocks the gpio is connected to a peripheral bus clock (clk_gpio). this clock is generated by the power manager. clk_gpio is enabled at reset, and can be disabled by writing to the power manager. clk_gpio must be enabled in order to access the configuration registers of the gpio or to use the gpio interrupts. after configuring the gpio, the clk_gpio can be disabled by writing to the power manager if interrupts are not used. 23.5.3 interrupts the gpio interrupt request lines are connected to the nvic. using the gpio interrupts requires the nvic to be programmed first. 23.5.4 peripheral events the gpio peripheral events are connected vi a the peripheral event system. refer to section 31. ?peripheral ev ent controller (pevc )? on page 844 for details. 23.5.5 debug operation when an external debugger forces the cpu into debug mode, the gpio continues normal oper- ation. if the gpio is configured in a way that requires it to be periodically serviced by the cpu through interrupts or similar, improper operation or data loss may result during debugging. pin name description type gpion gpio pin n digital
541 42023e?sam?07/2013 atsam4l8/l4/l2 23.6 functional description the gpio controls the i/o pins of the microcontr oller. the control logic associated with each pin is shown in the figure below. figure 23-2. overview of the gpio 0 1 gpio_odmer 0 1 0 1 gper 1 0 ovr oder pmrn periph. func. a periph.func. b periph. func. c pin puer* pvr 0 1 glitch filter gfer edge detector 1 0 interrupt request imr1 imr0 ier odcrn* osrrn* drive strength and slew rate control ster* schmitt trigger pder* pullup, pulldown and buskeeper .... output output enable input *) register value is overrided if a peripheral function that support this function is enabled ifr
542 42023e?sam?07/2013 atsam4l8/l4/l2 23.6.1 basic operation 23.6.1.1 module configuration the gpio user interface registers are organiz ed into ports and each port controls 32 different gpio pins. most of the registers supports bit wise access operations such as set, clear and tog- gle in addition to the standard word access. for details regarding interface registers, refer to section 23.7 . 23.6.1.2 available features the gpio features implemented are device dependent, and not all functions are implemented on all pins. the user must refer to the module configuration section and the gpio function mul- tiplexing section in the package and pinout chapter for the device specific settings used in the atsam4l8/l4/l2. device specific settings includes: ? number of gpio pins ? functions implemented on each pin ? peripheral function(s) multiplexed on each gpio pin ? reset state of registers 23.6.1.3 inputs the level on each gpio pin can be read through the pin value register (pvr). this register indicates the level of the gpio pins regardless of the pins being driven by the gpio or by an external component. note that due to power saving measures , the pvr register will only be updated when the corresponding bit in gper is one or if an interrupt is enabled for the pin, i.e. ier is one for the corresponding pin. 23.6.1.4 output control when the gpio pin is assigned to a peripheral function, i.e. the corresponding bit in gper is zero, the peripheral determines whether the pin is driven or not. when the gpio pin is controlled by the gpio, the value of output driver enable register (oder) determines whether the pin is driven or not. when a bit in this register is one, the corre- sponding gpio pin is driven by the gpio. when the bit is zero, the gpio does not drive the pin. the level driven on a gpio pin can be determined by writing the value to the corresponding bit in the output value register (ovr). 23.6.1.5 peripheral muxing the gpio allows a single gpio pin to be shared by multiple peripheral pins and the gpio itself. peripheral pins sharing the same gpio pin are arranged into peripheral functions that can be selected one at a time. peripheral functions are configured by writing the selected function value to the peripheral mux registers (pmrn). to allow a peripheral pin access to the shared gpio pin, gpio control must be disabled for that pin, i.e. the corresponding bit in gper must read zero. a peripheral function value is set by writing bit zero to pmr0 and bit one to the same index posi- tion in pmr1 and so on. in a system with 4 peripheral functions a,b,c, and d, peripheral function c for gpio pin four is selected by writi ng a zero to bit four in pmr0 and a one to the same bit index in pmr1. refer to the gpio function multiplexing chapter for details regarding pin function configuration for each gpio pin.
543 42023e?sam?07/2013 atsam4l8/l4/l2 23.6.2 advanced operation 23.6.2.1 peripheral i/o pin control when a gpio pin is assigned to a peripheral function, i.e. the corresponding bit in gper is zero, output and output enable is controlled by the selected peripheral pin. in addition the peripheral may control some or all of the other gpio pin functions listed in table 23-1 , if the peripheral sup- ports those features. all pin features not controlled by the selected peripheral is controlled by the gpio. refer to the module configuration section for details regarding implemented gpio pin functions and to the peripheral chapter for details regarding i/o pin function control. 23.6.2.2 pull-up resistor, pull-down resistor control pull-up and pull-down can be configured for each gpio pin. pull-up allows the pin and any con- nected net to be pulled up to vdd if the net is not driven. pull-down pulls the net to gnd. pull-up and pull-down are useful for detecting if a pin is unconnected or if a mechanical button is pressed, for various communication protocols an d to keep unconnected pins from floating. pull-up can be enabled and disabled by writing a one and a zero respectively to the correspond- ing bit in the pull-up enable register (puer). pu ll-down can be enabled and disabled by writing a one and a zero respectively to the correspondi ng bit in the pull-down en able register (pder). 23.6.2.3 output pin timings figure 23-3 shows the timing of the gpio pin when writing to the output value register (ovr). the same timing applies when performing a ?set? or ?clear? access, i.e. writing to ovrs or ovrc. the timing of pvr is also shown. table 23-1. i/o pin function control function name gpio mode peripheral mode output ovr peripheral output enable oder peripheral pull-up puer peripheral if supported, else gpio pull-down pder peripheral if supported, else gpio drive strength odcrn peripheral if supported, else gpio slew rate osrrn peripheral if supported, else gpio schmitt trigger ster peripheral if supported, else gpio
544 42023e?sam?07/2013 atsam4l8/l4/l2 figure 23-3. output pin timings 23.6.2.4 pin output driver control the gpio has registers for contro lling output drive propert ies of each pin, such as output driving capability and slew rate control. the driving capability is contro lled by the output driving capa bility registers (odcrn) and the slew rate settings are controlled by the output slew rate registers (osrrn). for a gpio pin with four different slew rate settings, a slew rate of two can be selected by writing a zero to the osrr0 register at the bit position corresponding to the gpio pin, and a one to the osrr1 at the same bit position. the odcrn registers are configur ed in the same way. 23.6.2.5 input schmitt trigger each gpio pin can be configured with an input schm itt trigger. an input schmitt trigger filters input signal using an hysteresis function, st opping noise from propagation into the system. the input schmitt trigger can be enabled and disabled by writing a one and a zero respectively to the schmitt trigger enable register (ster). 23.6.2.6 interrupts the gpio can be configured to generate an inte rrupt when it detects a change on a gpio pin. interrupts on a pin are enabled by writing a one to the corresponding bit in the interrupt enable register (ier). the module can be configured to generate an interrupt whenever a pin changes value, or only on rising or falling edges. this is controlled by the interrupt mode registers (imrn). interrupts on a pin can be enabled rega rdless of the gpio pin being controlled by the gpio or assigned to a peripheral function. an interrupt can be generated on each gpio pin. these interrupt generators are further grouped into groups of eight and connected to the nvic. an interrupt request from any of the gpio pin generators in the group will result in an interrupt request from that group to the nvic if the corre- sponding bit for the gpio pin in the ier is set. by grouping interrupt generators into groups of eight, four different interrupt handlers can be installed for each gpio port. the interrupt flag register (ifr) can be read by software to determine which pin(s) caused the interrupt. the interrupt flag must be manually cleared by writing a zero to the corresponding bit in ifr. gpio interrupts will only be gener ated when clk_gpio is enabled. 23.6.2.7 input glitch filter input glitch filters can be enabled on each gpio pi n. when the glitch filter is enabled, a glitch with duration of less than 1 clk_gpio cycle is automatically rejected, while a pulse with dura- pb access pb access clk_gpio write ovr to 1 write ovr to 0 ovr / i/o line pvr
545 42023e?sam?07/2013 atsam4l8/l4/l2 tion of 2 clk_gpio cycles or more is accepted. for pulse durations between 1 and 2 clk_gpio cycles, the pulse may or may not be taken into account, depending on the precise timing of its occurrence. thus for a pulse to be guaranteed visible it must exceed 2 clk_gpio cycles, whereas for a glitch to be reliably filtered out, its duration must not exceed 1 clk_gpio cycle. the filter introduces 2 clock cycles latency. the glitch filters are controlled by the glitch filter enable register (gfer). when a bit in gfer is one, the glitch filter on the corresponding pin is enabled. the glitch filter affects only interrupt inputs. inputs to peripherals or the value read through pvr are not affected by the glitch filters. 23.6.2.8 interrupt timings figure 23-4 shows the timing for rising edge (or pin-change) interrupts when the glitch filter is disabled. for the pulse to be registered, it must be sampled at the rising edge of the clock. in this example, this is not the case for the first pulse. the second pulse is sampled on a rising edge and will trigger an interrupt request. figure 23-4. interrupt timing with glitch filter disabled figure 23-5 shows the timing for rising edge (or pin-change) interrupts when the glitch filter is enabled. for the pulse to be registered, it must be sampled on two subsequent rising edges. in the example, the first pulse is rejected while th e second pulse is accepted and causes an inter- rupt request. figure 23-5. interrupt timing with g litch filter enabled 23.6.2.9 peripheral events peripheral events allow direct peripheral to peripheral communication of specified events. see section 31. ?peripheral event controller (pevc)? on page 844 for more information. the gpio can be programmed to output peripheral events whenever an interrupt condition is detected. the peripheral events configuration depends on the interrupt configuration. an event will be generated on the same condition as the interrupt (pin change, rising edge, or falling edge). the interrupt configuration is controlled by the imr register. peripheral event on a pin is enabled by writing a one to the corresponding bit in the event enable register (ever). the peripheral event trigger mode is shared with the interrupt trigger and is configured by writing to the imr0 and imr1 registers. interrupt does not need to be enabled on a pin when peripheral clk_gpio pin level ifr clk_gpio pin level ifr
546 42023e?sam?07/2013 atsam4l8/l4/l2 events are enabled. peripheral events are also affected by the input glitch filter settings. see section 23.6.2.7 for more information. a peripheral event can be generated on each gpio pin. each port can then have up to 32 peripheral event generators. gro ups of eight peripheral event g enerators in each port are ored together to form a peripheral event line, so that each port has four peripheral event lines con- nected to the peripheral event system.
547 42023e?sam?07/2013 atsam4l8/l4/l2 23.7 user interface the gpio controller manages all the gpio pins. the pins are managed as 32-bit ports that are configurable through a peripheral bus (pb) interface. each port has a set of configuration regis- ters. the overall memory map of the gpio is shown below. the number of pins and hence the number of ports is product specific. figure 23-6. port configuration registers in the peripheral muxing table in the package and pinout chapter each gpio pin has a unique number. note that the pa, pb, pc, and px ports do not necessarily directly correspond to the gpio ports. to find the corresponding port and pin the following formulas can be used: gpio port = floor((gpio number) / 32), example: floor((36)/32) = 1 gpio pin = gpio number % 32, example: 36 % 32 = 4 table 23-2 shows the configuration registers for one port. addresses shown are relative to the port address offset. the specific address of a co nfiguration register is found by adding the regis- ter offset and the port offset to the gpio start address. one bit in each of the configuration registers corresponds to a gpio pin. 23.7.1 access types most configuration register can be accessed in four different ways. the first address location can be used to write the register directly. this address can also be used to read the register value. the following addresses facilitate th ree different types of write acce ss to the regi ster. performing a ?set? access, all bits written to one will be se t. bits written to zero will be unchanged by the operation. performing a ?clear? a ccess, all bits written to one will be cleared. bits written to zero will be unchanged by the operation. finally, a toggle access will toggle the value of all bits writ- port 0 configuration registers port 1 configuration registers port 2 configuration registers port n configuration registers 0x0000 0x0200 0x0400 n*0x200 ?.
548 42023e?sam?07/2013 atsam4l8/l4/l2 ten to one. again all bits written to zero remain unchanged. note that for some registers (e.g. ifr), not all access methods are permitted. note that for ports with less than 32 bits, the corresponding control registers will have unused bits. this is also the case for features that are not implemented for a specific pin. writing to an unused bit will have no effect. reading unused bits will always return 0. table 23-2. gpio register memory map offset register function register name access reset config. protection access protection 0x000 gpio enable register read/write gper read/write - (1) yn 0x004 gpio enable register set gpers write-only y n 0x008 gpio enable register clear gperc write-only y n 0x00c gpio enable register toggle gpert write-only y n 0x010 peripheral mux register 0 read/write pmr0 read/write - (1) y n 0x014 peripheral mux register 0 set pmr0s write-only y n 0x018 peripheral mux register 0 clear pmr0c write-only y n 0x01c peripheral mux register 0 toggle pmr0t write-only y n 0x020 peripheral mux register 1 read/write pmr1 read/write - (1) yn 0x024 peripheral mux register 1 set pmr1s write-only y n 0x028 peripheral mux register 1 clear pmr1c write-only y n 0x02c peripheral mux register 1 toggle pmr1t write-only y n 0x030 peripheral mux register 2 read/write pmr2 read/write - (1) y n 0x034 peripheral mux register 2 set pmr2s write-only y n 0x038 peripheral mux register 2 clear pmr2c write-only y n 0x03c peripheral mux register 2 toggle pmr2t write-only y n 0x040 output driver enable register read/write oder read/write - (1) yn 0x044 output driver enable register set oders write-only y n 0x048 output driver enable register clear oderc write-only y n 0x04c output driver enable register toggle odert write-only y n 0x050 output value register read/write ovr read/write - (1) n n 0x054 output value register set ovrs write-only n n 0x058 output value register clear ovrc write-only n n 0x05c output value register toggle ovrt write-only n n 0x060 pin value register read pvr read-only depe nding on pin states nn
549 42023e?sam?07/2013 atsam4l8/l4/l2 0x064 pin value register - - - n n 0x068 pin value register - - - n n 0x06c pin value register - - - n n 0x070 pull-up enable register read/write puer read/write - (1) y n 0x074 pull-up enable register set puers write-only y n 0x078 pull-up enable register clear puerc write-only y n 0x07c pull-up enable register toggle puert write-only y n 0x080 pull-down enable register read/write pder read/write (1) y n 0x084 pull-down enable register set pders write-only y n 0x088 pull-down enable register clear pderc write-only y n 0x08c pull-down enable register toggle pdert write-only y n 0x090 interrupt enable register read/write ier read/write - (1) n n 0x094 interrupt enable register set iers write-only n n 0x098 interrupt enable register clear ierc write-only n n 0x09c interrupt enable register toggle iert write-only n n 0x0a0 interrupt mode register 0 read/write imr0 read/write - (1) nn 0x0a4 interrupt mode register 0 set imr0s write-only n n 0x0a8 interrupt mode register 0 clear imr0c write-only n n 0x0ac interrupt mode register 0 toggle imr0t write-only n n 0x0b0 interrupt mode register 1 read/write imr1 read/write - (1) n n 0x0b4 interrupt mode register 1 set imr1s write-only n n 0x0b8 interrupt mode register 1 clear imr1c write-only n n 0x0bc interrupt mode register 1 toggle imr1t write-only n n 0x0c0 glitch filter enable register read/write gfer read/write - (1) nn 0x0c4 glitch filter enable register set gfers write-only n n 0x0c8 glitch filter enable register clear gferc write-only n n 0x0cc glitch filter enable register toggle gfert write-only n n 0x0d0 interrupt flag register read ifr read-only - (1) n n 0x0d4 interrupt flag register - - - n n 0x0d8 interrupt flag register clear ifrc write-only n n 0x0dc interrupt flag register - - - n n 0x100 output driving capability regi ster 0 read/write odcr0 read/write - (1) yn 0x104 output driving capability register 0 set odcr0s write-only y n 0x108 output driving capability register 0 clear odcr0c write-only y n 0x10c output driving capability register 0 toggle odcr0t write-only y n table 23-2. gpio register memory map offset register function register name access reset config. protection access protection
550 42023e?sam?07/2013 atsam4l8/l4/l2 note: 1. the reset values for these registers ar e device specific. refer to the module co nfiguration section at the end of this c hapter. 0x110 output driving capability register 1 read odcr1 read/write - (1) y n 0x114 output driving capability register 1 set odcr1s write-only y n 0x118 output driving capability register 1 clear odcr1c write-only y n 0x11c output driving capability register 1 toggle odcr1t write-only y n 0x130 output slew rate register 0 read osrr0 read/write y n 0x134 output slew rate register 0 set osrr0s write-only y n 0x138 output slew rate register 0 clear osrr0c write-only y n 0x13c output slew rate register 0 toggle osrr0t write-only y n 0x160 schmitt trigger enable register read ster read/write - (1) y n 0x164 schmitt trigger enable register set sters write-only y n 0x168 schmitt trigger enable register clear sterc write-only y n 0x16c schmitt trigger enable register toggle stert write-only y n 0x180 event enable register read ever read/write - (1) n n 0x184 event enable register set evers write-only n n 0x188 event enable register clear everc write-only n n 0x18c event enable register toggle evert write-only n n 0x1f8 parameter register read pa r a m e t e r read-only - (1) n n 0x1fc version register read version read-only - (1) n n table 23-2. gpio register memory map offset register function register name access reset config. protection access protection
551 42023e?sam?07/2013 atsam4l8/l4/l2 23.7.2 gpio enable register name: gper access: read/write, set, clear, toggle offset : 0x000, 0x004, 0x008, 0x00c reset value: - ? p0-p31: gpio enable 0: a peripheral function controls the corresponding pin. 1: the gpio controls the corresponding pin. 31 30 29 28 27 26 25 24 p31 p30 p29 p28 p27 p26 p25 p24 23 22 21 20 19 18 17 16 p23 p22 p21 p20 p19 p18 p17 p16 15 14 13 12 11 10 9 8 p15 p14 p13 p12 p11 p10 p9 p8 76543210 p7 p6 p5 p4 p3 p2 p1 p0
552 42023e?sam?07/2013 atsam4l8/l4/l2 23.7.3 peripheral mux register 0 name: pmr0 access: read/write, set, clear, toggle offset : 0x010, 0x014, 0x018, 0x01c reset value: - ? p0-31: peripheral mult iplexer select bit 0 31 30 29 28 27 26 25 24 p31 p30 p29 p28 p27 p26 p25 p24 23 22 21 20 19 18 17 16 p23 p22 p21 p20 p19 p18 p17 p16 15 14 13 12 11 10 9 8 p15 p14 p13 p12 p11 p10 p9 p8 76543210 p7 p6 p5 p4 p3 p2 p1 p0
553 42023e?sam?07/2013 atsam4l8/l4/l2 23.7.4 peripheral mux register 1 name: pmr1 access: read/write, set, clear, toggle offset : 0x020, 0x024, 0x028, 0x02c reset value: - ? p0-31: peripheral mult iplexer select bit 1 31 30 29 28 27 26 25 24 p31 p30 p29 p28 p27 p26 p25 p24 23 22 21 20 19 18 17 16 p23 p22 p21 p20 p19 p18 p17 p16 15 14 13 12 11 10 9 8 p15 p14 p13 p12 p11 p10 p9 p8 76543210 p7 p6 p5 p4 p3 p2 p1 p0
554 42023e?sam?07/2013 atsam4l8/l4/l2 23.7.5 peripheral mux register 2 name: pmr2 access: read/write, set, clear, toggle offset : 0x030, 0x034, 0x038, 0x03c reset value: - ? p0-31: peripheral mult iplexer select bit 2 31 30 29 28 27 26 25 24 p31 p30 p29 p28 p27 p26 p25 p24 23 22 21 20 19 18 17 16 p23 p22 p21 p20 p19 p18 p17 p16 15 14 13 12 11 10 9 8 p15 p14 p13 p12 p11 p10 p9 p8 76543210 p7 p6 p5 p4 p3 p2 p1 p0 {pmr2, pmr1, pmr0} selected peripheral function 000 a 001 b 010 c 011 d 100 e 101 f 110 g 111 h
555 42023e?sam?07/2013 atsam4l8/l4/l2 23.7.6 output driver enable register name: oder access: read/write, set, clear, toggle offset : 0x040, 0x044, 0x048, 0x04c reset value: - ? p0-31: output driver enable 0: the output driver is disabled for the corresponding pin. 1: the output driver is enabled for the corresponding pin. 31 30 29 28 27 26 25 24 p31 p30 p29 p28 p27 p26 p25 p24 23 22 21 20 19 18 17 16 p23 p22 p21 p20 p19 p18 p17 p16 15 14 13 12 11 10 9 8 p15 p14 p13 p12 p11 p10 p9 p8 76543210 p7 p6 p5 p4 p3 p2 p1 p0
556 42023e?sam?07/2013 atsam4l8/l4/l2 23.7.7 output value register name: ovr access: read/write, set, clear, toggle offset : 0x050, 0x054, 0x058, 0x05c reset value: - ? p0-31: output value 0: the value to be driven on the gpio pin is 0. 1: the value to be driven on the gpio pin is 1. 31 30 29 28 27 26 25 24 p31 p30 p29 p28 p27 p26 p25 p24 23 22 21 20 19 18 17 16 p23 p22 p21 p20 p19 p18 p17 p16 15 14 13 12 11 10 9 8 p15 p14 p13 p12 p11 p10 p9 p8 76543210 p7 p6 p5 p4 p3 p2 p1 p0
557 42023e?sam?07/2013 atsam4l8/l4/l2 23.7.8 pin value register name: pvr access: read-only offset : 0x060, 0x064, 0x068, 0x06c reset value: depending on pin states ? p0-31: pin value 0: the gpio pin is at level zero. 1: the gpio pin is at level one. note that the level of a pin can only be read when the corresponding pin in gper is one or interrupt is enabled for the pin. 31 30 29 28 27 26 25 24 p31 p30 p29 p28 p27 p26 p25 p24 23 22 21 20 19 18 17 16 p23 p22 p21 p20 p19 p18 p17 p16 15 14 13 12 11 10 9 8 p15 p14 p13 p12 p11 p10 p9 p8 76543210 p7 p6 p5 p4 p3 p2 p1 p0
558 42023e?sam?07/2013 atsam4l8/l4/l2 23.7.9 pull-up enable register name: puer access: read/write, set, clear, toggle offset : 0x070, 0x074, 0x078, 0x07c reset value: - ? p0-31: pull-up enable writing a zero to a bit in this register will disable pull-up on the corresponding pin. writing a one to a bit in this register will enable pull-up on the corresponding pin. 31 30 29 28 27 26 25 24 p31 p30 p29 p28 p27 p26 p25 p24 23 22 21 20 19 18 17 16 p23 p22 p21 p20 p19 p18 p17 p16 15 14 13 12 11 10 9 8 p15 p14 p13 p12 p11 p10 p9 p8 76543210 p7 p6 p5 p4 p3 p2 p1 p0
559 42023e?sam?07/2013 atsam4l8/l4/l2 23.7.10 pull-down enable register name: pder access: read/write, set, clear, toggle offset : 0x080, 0x084, 0x088, 0x08c reset value: - ? p0-31: pull-down enable 31 30 29 28 27 26 25 24 p31 p30 p29 p28 p27 p26 p25 p24 23 22 21 20 19 18 17 16 p23 p22 p21 p20 p19 p18 p17 p16 15 14 13 12 11 10 9 8 p15 p14 p13 p12 p11 p10 p9 p8 76543210 p7 p6 p5 p4 p3 p2 p1 p0 {puer, pder} selected function 00 disabled 01 pull-down enabled 10 pull-up enabled 11 buskeeper enabled
560 42023e?sam?07/2013 atsam4l8/l4/l2 23.7.11 interrupt enable register name: ier access: read/write, set, clear, toggle offset : 0x090, 0x094, 0x098, 0x09c reset value: - ? p0-31: interrupt enable 0: interrupt is disabled for the corresponding pin. 1; interrupt is enabled for the corresponding pin. 31 30 29 28 27 26 25 24 p31 p30 p29 p28 p27 p26 p25 p24 23 22 21 20 19 18 17 16 p23 p22 p21 p20 p19 p18 p17 p16 15 14 13 12 11 10 9 8 p15 p14 p13 p12 p11 p10 p9 p8 76543210 p7 p6 p5 p4 p3 p2 p1 p0
561 42023e?sam?07/2013 atsam4l8/l4/l2 23.7.12 interrupt mode register 0 name: imr0 access: read/write, set, clear, toggle offset : 0x0a0, 0x0a4, 0x0a8, 0x0ac reset value: - ? p0-31: interrupt mode bit 0 31 30 29 28 27 26 25 24 p31 p30 p29 p28 p27 p26 p25 p24 23 22 21 20 19 18 17 16 p23 p22 p21 p20 p19 p18 p17 p16 15 14 13 12 11 10 9 8 p15 p14 p13 p12 p11 p10 p9 p8 76543210 p7 p6 p5 p4 p3 p2 p1 p0
562 42023e?sam?07/2013 atsam4l8/l4/l2 23.7.13 interrupt mode register 1 name: imr1 access: read/write, set, clear, toggle offset : 0x0b0, 0x0b4, 0x0b8, 0x0bc reset value: - ? p0-31: interrupt mode bit 1 31 30 29 28 27 26 25 24 p31 p30 p29 p28 p27 p26 p25 p24 23 22 21 20 19 18 17 16 p23 p22 p21 p20 p19 p18 p17 p16 15 14 13 12 11 10 9 8 p15 p14 p13 p12 p11 p10 p9 p8 76543210 p7 p6 p5 p4 p3 p2 p1 p0 {imr1, imr0} interrupt mode 00 pin change 01 rising edge 10 falling edge 11 reserved
563 42023e?sam?07/2013 atsam4l8/l4/l2 23.7.14 glitch filter enable register name: gfer access: read/write, set, clear, toggle offset : 0x0c0, 0x0c4, 0x0c8, 0x0cc reset value: - ? p0-31: glitch filter enable 0: glitch filter is disabled for the corresponding pin. 1: glitch filter is enabled for the corresponding pin. the value of this register should only be changed when the corre sponding bit in ier is zero. updating gfer while interrupt on the corresponding pin is enabled can cause an unintentional interrupt to be triggered. 31 30 29 28 27 26 25 24 p31 p30 p29 p28 p27 p26 p25 p24 23 22 21 20 19 18 17 16 p23 p22 p21 p20 p19 p18 p17 p16 15 14 13 12 11 10 9 8 p15 p14 p13 p12 p11 p10 p9 p8 76543210 p7 p6 p5 p4 p3 p2 p1 p0
564 42023e?sam?07/2013 atsam4l8/l4/l2 23.7.15 interrupt flag register name: ifr access: read, clear offset :0x0d0, 0x0d8 reset value: - ? p0-31: interrupt flag 0: no interrupt condition has been detected on the corresponding pin. 1: an interrupt condition has been detected on the corresponding pin. the number of interrupt request lines depe nds on the number of gpio pins on the mcu. refer to the product specific data for details. note also that a bit in the interrupt flag register is only valid if the corresponding bit in ier is one. 31 30 29 28 27 26 25 24 p31 p30 p29 p28 p27 p26 p25 p24 23 22 21 20 19 18 17 16 p23 p22 p21 p20 p19 p18 p17 p16 15 14 13 12 11 10 9 8 p15 p14 p13 p12 p11 p10 p9 p8 76543210 p7 p6 p5 p4 p3 p2 p1 p0
565 42023e?sam?07/2013 atsam4l8/l4/l2 23.7.16 output driving capability register 0 name: odcr0 access: read/write, set, clear, toggle offset : 0x100, 0x104, 0x108, 0x10c reset value: - ? p0-31: output driving capability register bit 0 31 30 29 28 27 26 25 24 p31 p30 p29 p28 p27 p26 p25 p24 23 22 21 20 19 18 17 16 p23 p22 p21 p20 p19 p18 p17 p16 15 14 13 12 11 10 9 8 p15 p14 p13 p12 p11 p10 p9 p8 76543210 p7 p6 p5 p4 p3 p2 p1 p0
566 42023e?sam?07/2013 atsam4l8/l4/l2 23.7.17 output driving capability register 1 name: odcr1 access: read/write, set, clear, toggle offset : 0x110, 0x114, 0x118, 0x11c reset value: - ? p0-31: output driving capability bit 1 for the actual drive strength of the pin, refer to section 42. ?electrical characteristics? on page 1120 . 31 30 29 28 27 26 25 24 p31 p30 p29 p28 p27 p26 p25 p24 23 22 21 20 19 18 17 16 p23 p22 p21 p20 p19 p18 p17 p16 15 14 13 12 11 10 9 8 p15 p14 p13 p12 p11 p10 p9 p8 76543210 p7 p6 p5 p4 p3 p2 p1 p0 {odcr1, odcr0} interrupt mode 00 lowest drive strength 01 ... 10 ... 11 highest drive strength
567 42023e?sam?07/2013 atsam4l8/l4/l2 23.7.18 output slew rate register 0 name: osrr0 access: read/write, set, clear, toggle offset : 0x130, 0x134, 0x138, 0x13c reset value: - ? p0-31: output slew rate control enable 0: slew rate control is disabled for the corresponding pin. 1: slew rate control is enabled for the corresponding pin. 31 30 29 28 27 26 25 24 p31 p30 p29 p28 p27 p26 p25 p24 23 22 21 20 19 18 17 16 p23 p22 p21 p20 p19 p18 p17 p16 15 14 13 12 11 10 9 8 p15 p14 p13 p12 p11 p10 p9 p8 76543210 p7 p6 p5 p4 p3 p2 p1 p0
568 42023e?sam?07/2013 atsam4l8/l4/l2 23.7.19 schmitt trigger enable register name: ster access: read/write, set, clear, toggle offset : 0x160, 0x164, 0x168, 0x16c reset value: - ? p0-31: schmitt trigger enable 0: schmitt trigger is disabled for the corresponding pin. 1: schmitt trigger is enabled for the corresponding pin. 31 30 29 28 27 26 25 24 p31 p30 p29 p28 p27 p26 p25 p24 23 22 21 20 19 18 17 16 p23 p22 p21 p20 p19 p18 p17 p16 15 14 13 12 11 10 9 8 p15 p14 p13 p12 p11 p10 p9 p8 76543210 p7 p6 p5 p4 p3 p2 p1 p0
569 42023e?sam?07/2013 atsam4l8/l4/l2 23.7.20 event enable register name: ever access: read/write, set, clear, toggle offset : 0x180, 0x184, 0x188, 0x18c reset value: - ? p0-31: event enable 0: peripheral event is disabled for the corresponding pin. 1: peripheral event is enabled for the corresponding pin. 31 30 29 28 27 26 25 24 p31 p30 p29 p28 p27 p26 p25 p24 23 22 21 20 19 18 17 16 p23 p22 p21 p20 p19 p18 p17 p16 15 14 13 12 11 10 9 8 p15 p14 p13 p12 p11 p10 p9 p8 76543210 p7 p6 p5 p4 p3 p2 p1 p0
570 42023e?sam?07/2013 atsam4l8/l4/l2 23.7.21 parameter register name: parameter access type: read-only offset :0x1f8 reset value: - ? parameter: 0: the corresponding pin is not implemented in this gpio port. 1: the corresponding pin is implemented in this gpio port. there is one parameter register per gpio port. each bit in the parameter register indica tes whether the corresponding gper bit is implemented. 31 30 29 28 27 26 25 24 pa r a m e t e r 23 22 21 20 19 18 17 16 pa r a m e t e r 15 14 13 12 11 10 9 8 pa r a m e t e r 76543210 pa r a m e t e r
571 42023e?sam?07/2013 atsam4l8/l4/l2 23.7.22 version register name: version access type: read-only offset :0x1fc reset value: - ? variant: variant number reserved. no functionality associated. ? version: version number version number of the module. no functionality associated. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 ---- variant 15 14 13 12 11 10 9 8 ---- version[11:8] 76543210 version[7:0]
572 42023e?sam?07/2013 atsam4l8/l4/l2 23.8 module configuration the specific configuration for each gpio instance is listed in the following tables. the module bus clocks listed here are connected to the system bus clocks. refer to section 10. ?power man- ager (pm)? on page 108 for details. the reset values for all gpio registers are zero, with the following exceptions: table 23-3. gpio configuration feature 48 pin package 64-pin package 100-pin package number of gpio ports 1 2 3 number of peripheral functions 8 8 8 table 23-4. implemented pin functions pin function implemented notes pull-up on all pins controlled by puer or peripheral pull-down on all pins controlled by pder or peripheral slew rate on all pins controlled by osrr or peripheral drive strength on all pins controlled by odcr or peripheral schmitt trigger enable on all pins controlled by ster or peripheral table 23-5. gpio clocks clock name description clk_gpio clock for the gpio bus interface table 23-6. register reset values port register reset value 0 gper 0xffffffff 0 pmr0 0x00000008 0 pmr1 0x00000000 0 pmr2 0x00000000 0 puer 0x00000000 0 gfer 0x00000000 0 parameter 0xfffffffc 0 version 0x00000215 1 gper 0x0000ffff 1 pmr0 0x00000000 1 pmr1 0x00000000
573 42023e?sam?07/2013 atsam4l8/l4/l2 1 pmr2 0x00000000 1 puer 0x00000000 1 gfer 0x00000000 1 parameter 0x000ffff 1 version 0x00000215 2 gper 0x00000000 2 pmr0 0x00000000 2 pmr1 0x00000000 2 pmr2 0x00000000 2 puer 0x00000000 2 gfer 0x00000000 2 parameter 0xffffffff 2 version 0x00000215 table 23-6. register reset values port register reset value
574 42023e?sam?07/2013 atsam4l8/l4/l2 24. universal synchronous asynchrono us receiver transmitter (usart) rev: 6.0.2.6 24.1 features ? configurable baud rate generator ? 5- to 9-bit full-duplex, synchronous and asynchronous, se rial communication ? 1, 1.5, or 2 stop bits in asynchrono us mode, and 1 or 2 in synchronous mode ? parity generation and error detection, with both normal and inverted data streams ? framing- and overrun error detection ? msb- or lsb-first ? optional break generation and detection ? receiver frequency oversampling by 8 or 16 times ? optional rts-cts hardware handshaking ? optional dtr-dsr-dcd-ri modem signal management ? receiver time-out and transmitter timeguard ? optional multidrop mode with address generation and detection ? rs485 with line driver control ? iso7816, t=0 and t=1 protocols for interfacing with smart cards ? inverted data management, nack handlin g, and customizable error counter ? irda modulation and demodulation ? communication at up to 115.2kbit/s ? spi mode ? master or slave ? configurable serial clock phase and polarity ? clk spi serial clock frequency up to a quarte r of the clk_usart internal clock frequency ? lin mode ? compliant with lin 1.3 and lin 2.0 sp ecifications ? master or slave ? processing of frames with up to 256 data bytes ? configurable response data length, optiona lly defined automatica lly by the identifier ? self synchronization in slave node configuration ? automatic processing and verification of the ?break field? and ?sync field? ? the ?break field? is detected even if it is partially superimposed with a data byte ? optional, automatic iden tifier parity management ? optional, automatic checksum management ? supports both ?classic? an d ?enhanced? checksum types ? full lin error checking and reporting ? frame slot mode: the master allocates slots to scheduled frames automatically. ? wakeup signal generation ? test modes ? automatic echo, remote- and local loopback ? supports two peripheral dma controller channels ? buffer transfers without processor intervention 24.2 overview the universal synchronous asynchronous receiver transmitter (usart) provides a full duplex, universal, synchronous/asynchronous serial link. data frame format is widely configu- rable, including basic length, parity, and stop bit settings, maximizing standards support. the receiver implements parity-, framing-, and overrun error detection, and can handle un-fixed
575 42023e?sam?07/2013 atsam4l8/l4/l2 frame lengths with the time-out feature. the usart supports several operating modes, provid- ing an interface to rs485, lin, and spi buses, with iso7816 t=0 and t=1 smart card slots, and infrared transceivers, and modem port connections. communication with slow and remote devices is eased by the timeguard. duplex multidrop communication is supported by address and data differentiation through the parity bi t. the hardware handshaking feature enables an out-of-band flow control, automatically managing rts and cts pins. the peripheral dma con- troller connection enables memory transactions , and the usart supports chained buffer management without processor intervention. automatic echo, remote-, and local loopback test modes are also supported. 24.3 block diagram figure 24-1. usart block diagram peripheral dma controller channel channel interrupt controller power manager div receiver transmitter modem signals control user interface i/o controller rxd rts txd cts dtr dsr dcd ri clk baudrate generator usart interrupt clk_usart clk_usart/div usart peripheral bus
576 42023e?sam?07/2013 atsam4l8/l4/l2 figure 24-2. usart block diagram peripheral dma controller channel channel interrupt controller power manager div receiver transmitter user interface i/o controller rxd rts txd cts clk baudrate generator usart interrupt clk_usart clk_usart/div usart peripheral bus table 24-1. spi operating mode pin usart spi slave spi master rxd rxd mosi miso txd txd miso mosi rts rts ? cs cts cts cs ?
577 42023e?sam?07/2013 atsam4l8/l4/l2 24.4 i/o lines description 24.5 product dependencies in order to use this module, other parts of the system must be configured correctly, as described below. 24.5.1 i/o lines the usart pins may be multiplexed with the i/o controller lines. the user must first configure the i/o controller to assign these pins to t heir peripheral functions. unused i/o lines may be used for other purposes. to prevent the txd line fr om falling when the usart is disabl ed, the use of an internal pull-up is required. if the hardware handshaking feature or modem mode is used, the internal pull-up on rts must also be enabled. all the pins of the modems may or may not be implemented on the usart. on usarts not equipped with the corresponding pins, the associat ed control bits and statuses have no effect on the behavior of the usart. 24.5.2 clocks the clock for the usart bus interface (clk_usart) is generated by the power manager. it is recommended to disable the usart before disab ling the clock, to avoid freezing the usart in an undefined state. 24.5.3 interrupts the usart interrupt request line is connected to the nvic. using the usart interrupt requires the nvic to be programmed first. table 24-2. i/o lines description name description type active level clk serial clock i/o txd transmit serial data or master out slave in (mosi) in spi master mode or master in slave out (miso) in spi slave mode output rxd receive serial data or master in slave out (miso) in spi master mode or master out slave in (mosi) in spi slave mode input ri ring indicator input low dsr data set ready input low dcd data carrier detect input low dtr data terminal ready output low cts clear to send or slave select (nss) in spi slave mode input low rts request to send or slave select (nss) in spi master mode output low
578 42023e?sam?07/2013 atsam4l8/l4/l2 24.6 functional description 24.6.1 usart operating modes the usart can operate in several modes: ?normal ? rs485, described in section 24.6.5 ?rs485 mode? on page 588 ? hardware handshaking, described in section 24.6.6 ?hardware handshaking? on page 589 ? modem, described in section 24.6.7 ?modem mode? on page 590 ? iso7816, described in section 24.6.8 ?iso7816 mode? on page 591 ? irda, described in section 24.6.9 ?irda mode? on page 594 ? lin master, described in section 24.6.10 ?lin mode? on page 596 ? lin slave, described in section 24.6.10 ?lin mode? on page 596 ? spi master, described in section 24.6.15 ?spi mode? on page 608 ? spi slave, described in section 24.6.15 ?spi mode? on page 608 the operating mode is selected by writing to the mode field in the ?mode register? (mr.mode). in addition, synchronous or asynchronous mode is selected by writing to the synchronous mode select bit in mr (mr.sync). by default, mr.mode and mr.sync are both zero, and the usart operates in normal asynchronous mode. 24.6.2 basic operation to start using the usart, the user must perform the following steps: 1. configure the baud rate by writing to the baud rate generator register (brgr) as described in ?baud rate generator? on page 586 2. select the operating mode by writing to the relevant fields in the mode register (mr) 3. enable the transmitter and/or receiver, by writing a one to cr.txen and/or cr.rxen respectively table 24-3. mr.mode mr.mode mode of the usart 0x0 normal 0x1 rs485 0x2 hardware handshaking 0x3 modem 0x4 is07816 protocol: t = 0 0x6 is07816 protocol: t = 1 0x8 irda 0xa lin master 0xb lin slave 0xe spi master 0xf spi slave others reserved
579 42023e?sam?07/2013 atsam4l8/l4/l2 4. check that csr.txrdy and/or csr.rxrdy is one before writing to thr and/or read- ing from rhr respectively 24.6.2.1 receiver and transmitter control after a reset, the transceiver is disabled. the re ceiver/transmitter is enabled by writing a one to the receiver enable/transmitter enable bit in the control register (cr.rxen/cr.txen) respectively. they may be enabled together and can be configured both before and after they have been enabled. the user can reset the usart receiver/transmitter at any time by writing a one to the reset receiver/reset transmitte r bit (cr.rstrx/cr.rsttx) respectively. this software reset clears status bits and resets internal state machines, immediately halting any communication. the user interface configur ation registers will re tain their values. the user can disable the receiver/transmitter by writing a one to either the receiver disable, or transmitter disable bit (cr.rxdis, or cr.txdis). if the receiver is disabled during a character reception, the usart will wait for the current character to be received before disabling. if the transmitter is disabled during transmission, the usart will wa it until both the current character and the character stored in the transmitter holding register (thr) are transmitted before dis- abling. if a timeguard ha s been implemented it will remain fu nctional during the transmission. 24.6.2.2 transmitter operations the transmitter operates equally in both synchronous and asynchronous operating modes (mr.sync). one start bit, up to 9 data bits, an optional parity bit, and up to two stop bits are successively shifted out on the txd pin at each falling edge of the serial clock. the number of data bits is selected by the character length fi eld (mr.chrl) and the 9-bit character length bit in the mode register (mr.mode9). nine bits are selected by writing a one to mr.mode9, over- riding any value in mr.chrl. the parity bit confi guration is selected in the mr.par field. the most significant bit first bit (mr.msbf) selects wh ich data bit to send first. the number of stop bits is selected by the mr.nbstop field. the 1.5 stop bit configuration is only supported in asynchronous mode. figure 24-3. character transmit the characters are sent by writing to the c haracter to be transmitted field (thr.txchr). the transmitter status can be read from the transmitter ready and transmitter empty bits in the channel status register (csr.txrdy/csr .txempty). csr.txrdy is set when thr is empty. csr.txempty is set when both thr and the transmit shift register are empty (trans- mission complete). an interrupt request is generated if the corresponding bit in the interrupt mask register (imr) is set (imr.tx rdy/imr.txempty). both csr.txrdy and csr.txempty are cleared when the transmitte r is disabled. csr.txrdy and csr.txempy can also be cleared by writing a one to the star t break bit in cr (cr.sttbrk). writing a char- acter to thr while csr.txrdy is zero has no effect and the written character will be lost. d0 d1 d2 d3 d4 d5 d6 d7 txd start bit parity bit stop bit example: 8-bit, parity enabled one stop baud rate clock
580 42023e?sam?07/2013 atsam4l8/l4/l2 figure 24-4. transmitter status 24.6.2.3 asynchronous receiver if the usart is configured in an asynchronous operating mode (mr.sync is zero), the receiver will oversample the rxd input line by either 8 or 16 times the baud rate clock, as selected by the oversampling mode bit (mr.over). if the line is zero for half a bit period (four or eight con- secutive samples, re spectively), a start bit will be assumed, and the follo wing 8th or 16th sample will determine the logical value on the line, resultin g in bit values being determined at the middle of the bit period. the number of data bits, endianess, parity mode, and stop bits are selected by the same bits and fields as for the transmitter (mr. chrl, mr.mode9, mr .msbf, mr.par, and mr.nbstop). the synchronization mechanism will onl y consider one stop bi t, regardless of the used protocol, and when the first stop bit has b een sampled, the receiver will automatically begin looking for a new start bit, enabling resynchronization even if there is a protocol mismatch. fig- ure 24-5 and figure 24-6 illustrate start bit detection and character receptio n in asynchronous mode. figure 24-5. asynchronous star t bit detection d0 d1 d2 d3 d4 d5 d6 d7 txd start bit parity bit stop bit baud rate clock start bit write thr d0 d1 d2 d3 d4 d5 d6 d7 parity bit stop bit txrdy txempty sampling clock (x16) rxd start detection sampling baud rate clock rxd start rejection sampling 12345678 12345670 1234 12345678 9 10111213141516 d0 sampling
581 42023e?sam?07/2013 atsam4l8/l4/l2 figure 24-6. asynchronous mode character reception 24.6.2.4 synchronous receiver in synchronous mode (mr.sync is one), the re ceiver samples the rxd signal on each rising edge of the baud rate clock, as illu strated in figure 24-7 . if a low level is detected, it is consid- ered as a start bit. configuration bits and fields are the same as in asynchronous mode. figure 24-7. synchronous mode character reception figure 24-8. receiver status 24.6.2.5 receiver operations when a character reception is completed, it is transferred to the received character field in the receive holding register (rhr.rxchr), and th e receiver ready bit in the channel status register (csr.rxrdy) is set. an interrupt request is generated if the receiver ready bit in the d0 d1 d2 d3 d4 d5 d6 d7 rxd parity bit stop bit example: 8-bit, parity enabled baud rate clock start detection 16 samples 16 samples 16 samples 16 samples 16 samples 16 samples 16 samples 16 samples 16 samples 16 samples d0 d1 d2 d3 d4 d5 d6 d7 rxd start sampling parity bit stop bit example: 8-bit, parity enabled 1 stop baud rate clock d0 d1 d2 d3 d4 d5 d6 d7 rxd start bit parity bit stop bit baud rate clock write cr rxrdy ovre d0 d1 d2 d3 d4 d5 d6 d7 start bit parity bit stop bit rststa = 1 read rhr
582 42023e?sam?07/2013 atsam4l8/l4/l2 interrupt mask register (imr.rxrdy) is set. if csr.rxrdy is already set, rhr will be over- written and the overrun error bit (csr.ovre) is set. an interrupt request is generated if the overrun error bit in imr is set. reading rhr will clear csr.rxrdy, and writing a one to the reset status bit in the cont rol register (cr.rststa) w ill clear csr.ovre. refer to figure 24- 8 . 24.6.3 other considerations 24.6.3.1 parity the usart supports five parity modes, selected by mr.par: ? even parity ?odd parity ? parity forced to zero (space) ? parity forced to one (mark) ? no parity the par field also enables the multidrop mode, see ?multidrop mode? on page 583 . if even par- ity is selected (mr.par is 0x0), the parity bit will be zero if there is an even number of ones in the data character, and one if there is an odd number. for odd parity the reverse applies. if space or mark parity is chosen (mr.par is 0x2 or 0x3, respectively), the parity bit will always be a zero or one, respectively. see table 24-4 . the receiver will report parity er rors in csr.pare, unless parity is disabled. an in terrupt request is generated if the pare bit in the interrupt mask register is set (imr.pare). writing a one to cr.rststa will clear csr.pare. see figure 24-9 . figure 24-9. parity error table 24-4. parity bit examples alphanum character hex bin parity mode odd even mark space none a 0x41 0100 0001 1 0 1 0 - v 0x56 0101 0110 1 0 1 0 - r 0x52 0101 0010 0 1 1 0 - d0 d1 d2 d3 d4 d5 d6 d7 rxd start bit bad parity bit stop bit baud rate clock write cr pare rxrdy rststa = 1
583 42023e?sam?07/2013 atsam4l8/l4/l2 24.6.3.2 multidrop mode if mr.par is either 0x6 or 0x7, the usart r uns in multidrop mode. this mode differentiates data and address characters. data has the parity bit zero and addresses have a one. by writing a one to the send address bit (cr.senda) the us er will cause the next character written to thr to be transmitted as an addres s. receiving a character with a one as parity bi t will report parity error by setting csr.pare. an interrupt request is generated if the pare bit in the interrupt mask register is set (imr.pare). 24.6.3.3 transmitter timeguard the timeguard feature enables the usart to interface slow devices by inserting an idle state on the txd line in between two characters. this idle state corresponds to a long stop bit, whose duration is selected by the timeguard value field in the transmitter timeguard register (ttgr.tg). the transmitter will ho ld the txd line high for ttgr.tg bit periods, in addition to the number of stop bi ts. as illustrated in figure 24-10 , the behavior of txrdy and txempty is modified when tg has a non-zero value. if a pending character has been written to thr, the csr.txrdy bit will not be set un til this characters start bi t has been sent. csr.txempty will remain low until the timeguard transmission has completed. figure 24-10. timeguard operation d0 d1 d2 d3 d4 d5 d6 d7 txd start bit parity bit stop bit baud rate clock start bit tg = 4 write thr d0 d1 d2 d3 d4 d5 d6 d7 parity bit stop bit txrdy txempty tg = 4 table 24-5. maximum baud rate dependent timeguard durations baud rate (bit/sec) bit time (s) timeguard (ms) 1 200 833 212.50 9 600 104 26.56 14400 69.4 17.71 19200 52.1 13.28 28800 34.7 8.85 33400 29.9 7.63 56000 17.9 4.55 57600 17.4 4.43 115200 8.7 2.21
584 42023e?sam?07/2013 atsam4l8/l4/l2 24.6.3.4 receiver time-out the time-out value field in the receiver time-o ut register (rtor.to) enables handling of vari- able-length frames by detection of selectable idle durations on the rxd line. the value written to to is loaded to a decr emental counter, and unless it is ze ro, a time-out will occur when the amount of inactive bit periods matches the initial counter value. if a time-out has not occurred, the counter will reload an d restart every time a new characte r arrives. a time-out sets the receiver time-out bit in csr (c sr.timeout). an interrupt request is generated if the receiver time-out bit in the interrupt mask register (imr.timeout) is set. clearing timeout can be done in two ways: ? writing a one to the start time-out bit (cr.sttto). this also aborts count down until the next character has been received. ? writing a one to the reload and start time-out bit (cr.retto). this also reloads the counter and restarts count down immediately. figure 24-11. receiver time-o ut block diagram table 24-6. maximum time-out period baud rate (bit/sec) bit time (s) time-out (ms) 600 1 667 109 225 1 200 833 54 613 2 400 417 27 306 4 800 208 13 653 9 600 104 6 827 14400 69 4 551 19200 52 3 413 28800 35 2 276 33400 30 1 962 56000 18 1 170 57600 17 1 138 200000 5 328 16-bit time-out counter 0 to timeout baud rate clock = character received retto load clock 16-bit value sttto dq 1 clear
585 42023e?sam?07/2013 atsam4l8/l4/l2 24.6.3.5 framing error the receiver is capable of detecting framing erro rs. a framing error has occurred if a stop bit reads as zero. this can occur if the transmitter and receiver are not synchronized. a framing error is reported by csr.frame as soon as the error is detected, at the middle of the stop bit. an interrupt request is generated if the framing error bit in the interrupt mask register (imr.frame) is set. csr.frame is cl eared by writing a one to cr.rststa. figure 24-12. framing error status 24.6.3.6 transmit break when csr.txrdy is set, the user can request the transmitter to generate a break condition on the txd line by writing a one to the start break bit (cr.sttbrk). the break is treated as a nor- mal 0x00 character transmission, clearing csr.txrdy and csr.txempty, but with zeroes for preambles, start, parity, stop, and time guard bits. writing a one to the stop break bit (cr.stt- brk) will stop the generation of new break charac ters, and send ones for tg duration or at least 12 bit periods, ensuring that the receiver detects end of break, before resuming normal opera- tion. figure 24-13 illustrates cr.sttbrk and cr.stpbrk effect on the txd line. writing to cr.sttbrk and cr.stpbrk simult aneously can lead to unpredictable results. writes to thr before a pendin g break has started will be ignored. figure 24-13. break transmission d0 d1 d2 d3 d4 d5 d6 d7 rxd start bit parity bit stop bit baud rate clock write cr frame rxrdy rststa = 1 d0 d1 d2 d3 d4 d5 d6 d7 txd start bit parity bit stop bit baud rate clock write cr txrdy txempty stpbrk = 1 sttbrk = 1 break transmission end of break
586 42023e?sam?07/2013 atsam4l8/l4/l2 24.6.3.7 receive break a break condition is assumed when incoming data, parity, and stop bits are zero. this corre- sponds to a framing error, but csr.frame will remain zero while the break received/end of break bit (csr.rxbrk) is set. an interrupt request is generated if the breadk received/end of break bit in the interrupt mask register is set (imr.rxbrk). writing a one to cr.rststa will clear csr.rxbrk. an end of break will also set csr.rxbrk, and is assumed when tx is high for at least 2/16 of a bit period in asynchronous mode, or when a high level is sampled in syn- chronous mode. 24.6.4 baud rate generator the baud rate generator provides the bit period clock named the baud rate clock to both receiver and transmitter. it is based on a 16-bit di vider, which is specified in the clock divider field in the baud rate generator register (brgr.cd). a non-zero value enables the generator, and if brgr.cd is one, the divider is bypassed and inactive. the clock selection field in the mode register (mr.usclks) selects clock source between: ? clk_usart (internal clock, refer to power manager chapter for details) ? clk_usart/div (a divided clk_usart, refer to module configuration section) ? clk (external clock, available on the clk pin) if the external clock clk is selected, the duration of the low and high levels of the signal pro- vided on the clk pin must be at least 4.5 times longer than those provided by clk_usart. figure 24-14. baud rate generator 24.6.4.1 baud rate in asynchronous mode if the usart is configured to operate in asynchronous mode (mr.sync is zero), the selected clock is divided by the brgr.cd value before it is provided to the receiver as a sampling clock. depending on the oversampling mode bit (mr.over ) value, the clock is then divided by either 8 (mr.over=1), or 16 (mr.over=0). the baud rate is calculated with the following formula: 16-bit counter cd usclks cd clk_usart clk_usart/div reserved clk sync sync usclks= 3 fidi over sampling divider baudrate clock sampling clock 1 0 0 clk 0 1 2 3 >1 1 1 0 0 baudrate selectedclock 82 over ? () cd () ----------------------------------------------- - =
587 42023e?sam?07/2013 atsam4l8/l4/l2 this gives a maximum baud rate of clk_usar t divided by 8, assuming that clk_usart is the fastest clock available, and that mr.over is one. 24.6.4.2 baud rate calculation example table 24-7 shows calculations based on the cd field to obtain 38400 baud from different source clock frequencies. this table also shows the actual resulting baud rate and error. the baud rate is calculated with the following formula (mr.over=0): the baud rate error is calculated with the following formula. it is not recommended to work with an error higher than 5%. 24.6.4.3 fractional baud rate in asynchronous mode the baud rate generator has a limitation: the source frequency is always a multiple of the baud rate. an approach to this problem is to integrate a high resolution fractional n clock generator, outputting fractional multiples of the reference source clock. this fractional part is selected with table 24-7. baud rate example (over=0) source clock (hz) expected baud rate (bit/s) calculation result cd actual baud rate (bit/s) error 3 686 400 38 400 6.00 6 38 400.00 0.00% 4 915 200 38 400 8.00 8 38 400.00 0.00% 5 000 000 38 400 8.14 8 39 062.50 1.70% 7 372 800 38 400 12.00 12 38 400.00 0.00% 8 000 000 38 400 13.02 13 38 461.54 0.16% 12 000 000 38 400 19.53 20 37 500.00 2.40% 12 288 000 38 400 20.00 20 38 400.00 0.00% 14 318 180 38 400 23.30 23 38 908.10 1.31% 14 745 600 38 400 24.00 24 38 400.00 0.00% 18 432 000 38 400 30.00 30 38 400.00 0.00% 24 000 000 38 400 39.06 39 38 461.54 0.16% 24 576 000 38 400 40.00 40 38 400.00 0.00% 25 000 000 38 400 40.69 40 38 109.76 0.76% 32 000 000 38 400 52.08 52 38 461.54 0.16% 32 768 000 38 400 53.33 53 38 641.51 0.63% 33 000 000 38 400 53.71 54 38 194.44 0.54% 40 000 000 38 400 65.10 65 38 461.54 0.16% 50 000 000 38 400 81.38 81 38 580.25 0.47% 60 000 000 38 400 97.66 98 38 265.31 0.35% baudrate clk _ usart cd 16 ? ----------------------------------- = error 1 expectedbaudrate actualbaudrate -------------------------------------------------- - ?? ?? ? =
588 42023e?sam?07/2013 atsam4l8/l4/l2 the fractional part field in brgr (brgr.fp), and is activated by giving it a non-zero value. the resolution is one eighth of cd. the resulting baud rate is calculated using the following formula: the modified architecture is shown in figure 24-15 . figure 24-15. fractional baud rate generator 24.6.4.4 baud rate in synchronous and spi mode if the usart is configured to operate in synchronous mode (mr.sync is one), the selected clock is divided by brgr.cd. this does not a pply when the external clock clk is selected. when clk is selected, the frequency of the external clock must be at least 4.5 times lower than the system clock, and when either clk or cl k_usart/div are selected, brgr.cd must be even to ensure a 50/50 duty cycle. if clk_usart is selected, the generator ensures this regardless of value. 24.6.5 rs485 mode the usart features an rs485 mode, supporting line driver control. this supplements normal synchronous and asynchronous mode by driving the rts pin high when the transmitter is oper- ating. the rts pin level is the inverse of the csr.txempty value. the rs485 mode is enabled by writing 0x1 to mr.mode. a typi cal connection to a rs485 bus is shown in figure 24-16 . baudrate selectedclock 82 over ? () cd fp 8 ------- + ?? ?? ?? ?? -------------------------------------------------------------------- = usclks cd modulus control fp fp cd glitch-free logic 16-bit counter over sync sampling divider clk_usart clk_usart/div reserved clk clk baudrate clock sampling clock sync usclks = 3 >1 1 2 3 0 0 1 0 1 1 0 0 baudrate selectedclock cd ------------------------------------- - =
589 42023e?sam?07/2013 atsam4l8/l4/l2 figure 24-16. typical connection to a rs485 bus if a timeguard has been configured the rts pin will remain high fo r the duration specified in tg, as shown in figure 24-17 . figure 24-17. example of rts drive with timeguard enabled 24.6.6 hardware handshaking the usart features an out-of-band hardwar e handshaking flow control mechanism, imple- mentable by connecting the rts and cts pins with the remote device, as shown in figure 24- 18 . figure 24-18. connection with a remote device for hardware handshaking usart rts txd rxd differential bus d0 d1 d2 d3 d4 d5 d6 d7 txd start bit parity bit stop bit baud rate clock tg = 4 write thr txrdy txempty rts usart txd cts remote device rxd txd rxd rts rts cts
590 42023e?sam?07/2013 atsam4l8/l4/l2 writing 0x2 to the mr.mode field configures the usart to operate in hardware handshaking mode. the receiver will drive its rts pin high when disabled or when the reception buffer full bit (csr.rxbuff) is set by the buffer full signal from the peripheral dma controller. if the receiver rts pin is high, the transmitter cts pin will also be high and on ly the active character transmissions will be completed. allocating a ne w buffer to the dma controller by clearing rxbuff, will drive the rts pin low, allowing the transmitter to resume transmission. detected level changes on the cts pin are reported by the cts input change bit in the channel status register (csr.ctsic). an interrupt request is generated if the input change bit in the interrupt mask register is set. csr.ctsi c is cleared when reading csr. figure 24-19 illustrates receiver functionality, and figure 24-20 illustrates transmitter functionality. figure 24-19. receiver behavior when operating with hardware handshaking figure 24-20. transmitter behavior when operating with hardware handshaking 24.6.7 modem mode the usart features a modem mode, supporting asynchronous communication with the follow- ing signal pins: data terminal ready (dtr), data set ready (dsr), request to send (rts), clear to send (cts), data carrier detect (dcd), and ring indicator (ri). modem mode is enabled by writing 0x3 to mr.mode. the usart will behave as a data terminal equipment (dte), controlling dtr and rts, while detecting leve l changes on dsr, dcd, cts, and ri. table 24-8 shows usart signal pins with the corres ponding standardized modem connections. rts rxbuff write cr rxen = 1 rxd rxdis = 1 cts txd table 24-8. circuit references usart pin v.24 ccitt direction txd 2 103 from terminal to modem rts 4 105 from terminal to modem dtr 20 108.2 from terminal to modem rxd 3 104 from modem to terminal cts 5 106 from terminal to modem
591 42023e?sam?07/2013 atsam4l8/l4/l2 the dtr pin is controlled by the dtr enabl e and disable bits in cr (cr.dtren and cr.dtrdis). writing a one to cr.dtrdis driv es dtr high, and writing a one to cr.dtren drives dtr low. the rts pin is controlled automatically. detected level changes are reported by the re spective input change bits in csr (csr.riic, csr.dsric, csr.dcdic, and csr.ctsic). an interrupt request is generated if the corre- sponding bit in the interrupt mask register is set. the input change bits in csr are automatically cleared when csr is read. when the cts pin goes high, the usart will wait for the transmitter to complete any ongoing character transmission before automatically disabling it. 24.6.8 iso7816 mode the usart features an iso7816 compatible mode, enabling interfacing with smart cards and security access modules (sam) through an iso7816 compliant link. t=0 and t=1 protocols, as defined in the iso7816 standard, are supported. the iso7816 mode is selected by writing the value 0x4 (t=0 protocol) or 0x6 (t=1 protocol) to mr.mode. 24.6.8.1 iso7816 mode overview iso7816 specifies half duplex communication on on e bidirectional line. the baud rate is a frac- tion of the clock provided by the master on the clk pin (see ?baud rate generator? on page 586 ). the usart connects to a smart card as shown in figure 24-21 . the txd pin is bidirec- tional and is routed to the receiver when the tr ansmitter is disabled. having both receiver and transmitter enabled simultaneously may lead to unpredictable results. figure 24-21. usart (master) connected to a smart card in both t=0 and t=1 modes, the character format is fixed to eight data bits, and one or two stop bits, regardless of chrl, mode9, and chmode va lues. parity according to specification is even. if the inverse transmission format is used, where payload data bits are transmitted inverted on the i/o line, the user can either use odd parity and perform an xor on data headed to thr and coming from rhr, or write a one to mr.invdata and let the device handle the rest. 24.6.8.2 baud rate in iso 7816 mode the iso7816 specification defines the bit rate with the following formula: where: dsr 6 107 from terminal to modem dcd 8 109 from terminal to modem ri 22 125 from terminal to modem table 24-8. circuit references usart pin v.24 ccitt direction clk txd usart clk i/o smart card b di fi ----- - f =
592 42023e?sam?07/2013 atsam4l8/l4/l2 ? b is the bit rate ? di is the bit-rate adjustment factor ? fi is the clock frequency division factor ? f is the iso7816 clock frequency (hz) di is a binary value encoded on a 4-bit field, named di, as represented in table 24-9 . fi is a binary value encoded on a 4-bi t field, named fi, as represented in table 24-10 . table 24-11 shows the resulting fi/di ratio, which is the ratio between the iso7816 clock and the baud rate clock. the clock selected by mr.usclks can be output on the clk pin to feed the smart card clock inputs. to output the clock, the user must write a one to the clock output select bit in mr (mr.clko). the clock is divided by brgr.cd before it is output on the clk pin. if clk is selected as clock source in mr.usclks, the clock can not be output on the clk pin. the selected clock is divided by the fi over di ratio value field in the fi di ratio register (fidi.fi_di_ratio), which can be up to 2047 in iso7816 mode. this will be rounded off to an integral so the user has to select a fi_di_ratio value that comes as close as possible to the expected fi/di ratio. the fi_di_ratio reset value is 0x174 (372 in decimal) and is the most common divider between the iso7816 clock and bit rate (fi=372, di=1). figure 24-22 shows the relationship between the elementary time unit (etu), corresponding to a bit period, and the iso 7816 clock. table 24-9. binary and decimal values for di di field 0001 0010 0011 0100 0101 0110 1000 1001 di (decimal)1 2 4 8 163212 20 table 24-10. binary and decimal values for fi fi field 0000 0001 0010 0011 0100 0101 0110 1001 1010 1011 1100 1101 fi (decimal 372 372 558 744 1116 1488 1860 512 768 1024 1536 2048 table 24-11. possible values for the fi/di ratio fi 372 558 744 1116 1488 1860 512 768 1024 1536 2048 di=2 186 279 372 558 744 930 256 384 512 768 1024 di=4 93 139.5 186 279 372 465 128 192 256 384 512 di=8 46.5 69.75 93 139.5 186 232.5 64 96 128 192 256 di=16 23.25 34.87 46.5 69.75 93 116.2 32 48 64 96 128 di=32 11.62 17.43 23.25 34.87 46.5 58.13 16 24 32 48 64 di=12 31 46.5 62 93 124 155 42.66 64 85.33 128 170.6 di=20 18.6 27.9 37.2 55.8 74.4 93 25.6 38.4 51.2 76.8 102.4
593 42023e?sam?07/2013 atsam4l8/l4/l2 figure 24-22. elementary time unit (etu) 24.6.8.3 protocol t=0 in t=0 protocol, a character is made up of one star t bit, eight data bits, one parity bit, and a two bit period guard time. during the guard time, the line will be high if the receiver does not signal a parity error, as shown in figure 24-23 . the receiver signals a parity error, aka non-acknowledge (nack), by pulling the line low for a bit period within the guard time, resulting in the total charac- ter length being incremented by one, see figure 24-24 . the usart will not load data to rhr if it detects a parity error, and will set pare if it receives a nack. figure 24-23. t=0 protocol without parity error figure 24-24. t=0 protocol with parity error 24.6.8.4 protocol t=1 in t=1 protocol, the character resembles an asynchronous format with only one stop bit. the parity is generated when transmitting and checked when receiving. parity errors set pare. 24.6.8.5 receive error counter the usart receiver keeps count of up to 255 errors in the number of errors field in the num- ber of error register (ner.n b_errors). reading ner automatically clears nb_errors. 24.6.8.6 receive nack inhibit the usart can be configured to ignore parity errors by writing a one to the inhibit non acknowledge bit (mr.inack). erro neous characters will be treated as if they were ok, not gen- erating a nack, loaded to rhr, and raising rxrdy. 1 etu fi_di_ratio iso7816 clock cycles iso7816 clock on clk iso7816 i/o line on txd d0 d1 d2 d3 d4 d5 d6 d7 rxd parity bit baud rate clock start bit guard time 1 next start bit guard time 2 d0 d1 d2 d3 d4 d5 d6 d7 i/o parity bit baud rate clock start bit guard time 1 start bit guard time 2 d0 d1 error repetition
594 42023e?sam?07/2013 atsam4l8/l4/l2 24.6.8.7 transmit character repetition the usart can be configured to automatically re -send a character if it receives a nack. writ- ing a non-zero value to mr.max_iteration will enable and determine the number of consecutive re-transmissions. if the number of unsuccessful re-transmissions equals max_iteration, the iteration bit (csr.iter) is set. an interrupt request is generated if the iter bit in the interrupt mask register (imr.iter) is set. writing a one to the reset iteration bit (cr.rstit) will clear csr.iter. 24.6.8.8 disable successive receive nack the receiver can limit the number of consec utive nacks to the value in mr.max_iteration. this is enabled by writing a one to the disab le successive nack bit (mr.dsnack). if the num- ber of nacks is about to ex ceed mr.max_iteration, the ch aracter will instead be accepted as valid and csr.iter is set. 24.6.9 irda mode the usart features an irda mode, supporting asynchronous, half-duplex, point-to-point wire- less communication. it embeds the modulator and demodulator, allowing for a glueless connection to the infrared transceivers, as shown in figure 24-25 . the irda mode is enabled by writing 0x8 to mr.mode. this activates the ir da specification v1.1 compliant modem. data transfer speeds ranging from 2.4kbit/s to 115.2kbit/s are supported and the character format is fixed to one start bit, eight data bits, and one stop bit. figure 24-25. connection to irda transceivers the receiver and the transmitter must be exclusively enabled or disabled, according to the direc- tion of the transmission. to receive irda signals, the following needs to be done: ? disable tx and enable rx. ? configure the txd pin as an i/o, outputting zero to avoid led activation. disable the internal pull-up for improved power consumption. ? receive data. irda transceivers rxd rx txd tx usart demodulator modulator receiver transmitter
595 42023e?sam?07/2013 atsam4l8/l4/l2 24.6.9.1 irda modulation the rzi modulation scheme is used, where a zero is represented by a light pulse 3/16 of a bit period, and no pulse to represent a one. some examples of signal pulse duration are shown in table 24-12 . figure 24-26 shows an example of character transmission. figure 24-26. irda modulation 24.6.9.2 irda baud rate as the irda mode shares some logic with the iso7816 mode, the fidi.fi_di_ratio field must be configured correctly. see section ?24.6.16? on page 611. table 24-13 shows some examples of brgr.cd values, baud rate error, and pulse duration. note that the maximal acceptable error rate of 1.87% must be met. table 24-12. irda pulse duration baud rate pulse duration (3/16) 2.4 kbit/s 78.13 s 9.6 kbit/s 19.53 s 19.2 kbit/s 9.77 s 38.4 kbit/s 4.88 s 57.6 kbit/s 3.26 s 115.2 kbit/s 1.63 s bit period bit period 3 16 start bit data bits stop bit 0 0 0 0 0 1 1 1 1 1 transmitter output txd table 24-13. irda baud rate error peripheral clock baud rate cd baud rate error pulse time 3 686 400 115 200 2 0.00% 1.63 20 000 000 115 200 11 1.38% 1.63 32 768 000 115 200 18 1.25% 1.63 40 000 000 115 200 22 1.38% 1.63 3 686 400 57 600 4 0.00% 3.26 20 000 000 57 600 22 1.38% 3.26 32 768 000 57 600 36 1.25% 3.26 40 000 000 57 600 43 0.93% 3.26
596 42023e?sam?07/2013 atsam4l8/l4/l2 24.6.9.3 irda demodulator the demodulator depends on an 8-bit down counter loaded with the value in the irda_filter field in the irda filter register (ifr.irda_f ilter). when a falling edge on rxd is detected, the counter starts decrementing at clk_usart speed. if a rising edge on rxd is detected , the counter stops and is reloaded with the ird filter value. if no rising edge has been detected when the counter reaches zero, the receiver input is pulled low during one bit period, see figure 24- 27 . writing a one to the infrared receive line filter bit (mr.filter), enables a noise filter that, instead of using just one samp le, will choose the majority value from three consecutive samples. figure 24-27. irda demodulator operations 24.6.10 lin mode the usart features a local interconnect network (lin) 1.3 and 2.0 compliant mode, embed- ding full error checking and reporting, automatic frame processing with up to 256 data bytes, customizable response data lengths, and requiring minimal cpu resources. the lin mode is enabled by writing 0xa (master) or 0xb (slave) to mr.mode. 3 686 400 38 400 6 0.00% 4.88 20 000 000 38 400 33 1.38% 4.88 32 768 000 38 400 53 0.63% 4.88 40 000 000 38 400 65 0.16% 4.88 3 686 400 19 200 12 0.00% 9.77 20 000 000 19 200 65 0.16% 9.77 32 768 000 19 200 107 0.31% 9.77 40 000 000 19 200 130 0.16% 9.77 3 686 400 9 600 24 0.00% 19.53 20 000 000 9 600 130 0.16% 19.53 32 768 000 9 600 213 0.16% 19.53 40 000 000 9 600 260 0.16% 19.53 3 686 400 2 400 96 0.00% 78.13 20 000 000 2 400 521 0.03% 78.13 32 768 000 2 400 853 0.04% 78.13 table 24-13. irda baud rate error (continued) peripheral clock baud rate cd baud rate error pulse time clk_usart rxd counter value receiver input 654 6 3 pulse rejected 264 53210 pulse accepted driven low during 16 baud rate clock cycles
597 42023e?sam?07/2013 atsam4l8/l4/l2 24.6.10.1 modes of operation changing lin mode after initial configuration must be followed by a transceiver software reset in order to avoid unpredictable behavior. 24.6.10.2 receiver and transmitter control see section ?24.6.2.1? on page 579. 24.6.10.3 baud rate configuration the lin nodes baud rate is configured in the baud rate generator register (brgr), see sec- tion ?24.6.4.1? on page 586. the lin slave node copies the init ial brgr value to the lin baud rate register (linbrr), and updates linbrr after successful synchronization. 24.6.10.4 character transmission and reception see ?transmitter operations? on page 579 , and ?receiver operations? on page 581 . 24.6.10.5 header transmission (master node configuration) all lin frames start with a header sent by the master. as soon as the identifier has been written to the identifier character field in the lin identifier register (linir.idchr), csr.txrdy is cleared and the header is sent. the header consists of a break field, a sync field, and an identi- fier field. csr.txrdy is set when the identifier has been transferred into the transmitters shift register. an interrupt request is generated if imr.txrdy is set. the break field consists of 13 dominant bits (the break) and one recessive bit (the break delim- iter). the sync field consists of a start bit, th e sync byte (the character 0x55), and a stop bit, refer to figure 24-30 . the identifier field contains the ident ifier as written to linir.idchr. the identifier parity bits can be generated automatically (see section 24.6.10.8 ). figure 24-28. header transmission see also ?master node configuration? on page 603 . 24.6.10.6 header reception (slave node configuration) the usart stays idle until it detects a break field, consisting of at least 11 consecutive domi- nant bits (zeroes) on the bus. a received break will set the lin break bit (csr.linbk). an interrupt request is generated if the lin break bit in the interrupt mask register (imr.linbk) is set. the sync field is used to synchronize the baud rate (see section 24.6.10.7 ). idchr is updated and the lin identifier bit (csr.linid) is set when the identifier has been received. an interrupt request is generated if the lin identifier bit in the interrupt mask register (imr.linid) is set. the identifier parity bits can be automatically checked (see section 24.6.10.8 ). if the header txd baud rate clock start bit write linir 10101010 txrdy stop bit start bit id0 id1 id2 id3 id4 id5 id6 id7 break field 13 dominant bits (at 0) stop bit break delimiter 1 recessive bit (at 1) synch byte = 0x55 linir id
598 42023e?sam?07/2013 atsam4l8/l4/l2 is not received within the time defined in theader_maximum, the lin header time-out error (csr.linhte) is generated (see section 24.6.10.13 ). an interrupt request is generated if imr.linhte is set. writing a one to cr.rststa will clear csr.linhte, csr.linbk, and csr.linid. figure 24-29. header reception see also ?slave node configuration? on page 605 . 24.6.10.7 slave node synchronization synchronization is only done by the slave, and can be disabled by writing a one to the synchro- nization disable bit in the lin mode register (linmr.syncdis). if the sync byte is not 0x55, an inconsistent sync field error is generated, and th e lin inconsistend sync field error bit in csr (csr.linisfe) is set. an interrupt request is generated if the linisfe bit in imr is set. csr.linisfe is cleared by wr iting a one to cr.rststa. the time between falling edges is measured by a 19-bit counter, driven by the sampling clock (see section 24.6.4 ). figure 24-30. sync field the counter starts when the sync field start bit is detected, and continues for eight bit periods. if the deviation is within 15% (see below), the 16 mo st significant bits (counter value divided by 8) becomes the new clock divider (linbrr.lincd), and the three least significant bits (the remain- der) becomes the new fractional part (linbrr.linfp). break field 13 dominant bits (at 0) break delimiter 1 recessive bit (at 1) start bit 10101010 stop bit start bit id0 id1 id2 id4 id3 id6 id5 id7 stop bit synch byte = 0x55 baud rate clock rxd write us_cr with rststa=1 us_linir linid start bit stop bit synch field 8 tbit 2 tbit 2 tbit 2 tbit 2 tbit
599 42023e?sam?07/2013 atsam4l8/l4/l2 figure 24-31. slave node synchronization the synchronization accuracy depends on: ? the theoretical slave node clock frequency; nominal clock frequency (f nom ) ? the baud rate ? the oversampling mode (over=0 => 16x, or over=1 => 8x) the following formula is used to calculate synchronization deviation, where f slave is the real slave node clock frequency, and f tol_unsync is the difference between f nom and f slave . accord- ing to the lin specification, f tol_unsynch may not exceed 15%, and the bit rates between two nodes must be within 2% of each other, resulting in a maximal baudrate_deviation of 1%. if f tol_unsynch exceeds 15%, linbrr will not be updated with new values, and the lin sync tolerance error bit (csr.linste) is set. minimum nominal clock frequency with a fractional part: examples: ? baud rate = 20 kbit/s, over=0 (oversampling 16x) => f nom (min) = 2.64mhz ? baud rate = 20 kbit/s, over=1 (oversampling 8x) => f nom (min) = 1.47mhz ? baud rate = 1 kbit/s, over=0 (oversampling 16x) => f nom (min) = 132 khz ? baud rate = 1 kbit/s, over=1 (oversampling 8x) => f nom (min) = 74 khz if the fractional part is not used, the synchroniza tion accuracy is much lower. the 16 most signif- icant bits, added with the first least significant bit, becomes the new cloc k divider (lincd). the equation of the baud rate deviation is the same as above, but the constants are: rxd baud rate clock linidrx synchro counter 000_0011_0001_0110_1101 brgr clcok divider (cd) 0000_0110_0010_1101 brgr fractional part (fp) 101 initial cd initial fp reset start bit 10101010 stop bit start bit id0 id1 id2 id3 id4 id5 id6 id7 break field 13 dominant bits (at 0) stop bit break delimiter 1 recessive bit (at 1) synch byte = 0x55 baudrate_deviation 100 [ 8 2 over ? () + ] baudrate 8f slave -------------------------------------------------------------------------------------------------- - ?? ?? % = baudrate_deviation 100 [ 8 2 over ? () + ] baudrate 8 f tol_unsync 100 ----------------------------------- - ?? ?? xf nom -------------------------------------------------------------------------------------------------- - ?? ?? ?? ?? ?? % = 0.5 ? +0.5 -1 +1 << ? () 100 0.5 8 2 over ? () 1 + [] baudrate 8 15 ? 100 --------- - 1 + ?? ?? 1% ------------------------------------------------------------------------------------------------------ - ?? ?? ?? ?? ?? hz =
600 42023e?sam?07/2013 atsam4l8/l4/l2 minimum nominal clock frequency without a fractional part: examples: ? baud rate = 20 kbit/s, over=0 (oversampling 16x) => f nom (min) = 19.12mhz ? baud rate = 20 kbit/s, over=1 (oversampling 8x) => f nom (min) = 9.71mhz ? baud rate = 1 kbit/s, over=0 (oversampling 16x) => f nom (min) = 956 khz ? baud rate = 1 kbit/s, over=1 (oversampling 8x) => f nom (min) = 485 khz 24.6.10.8 identifier parity an identifier field consists of two sub-fields; the identifier and its parity. bits 0 to 5 are assigned to the identifier, while bits 6 and 7 are assigned to parity. automatic parity management is enabled by default, and can be di sabled by writing a one to the parity disable bit in the lin mode register (linmr.pardis). ? linmr.pardis=0: during header transmission, the parity bits are computed and in the shift register they replace bits 6 and 7 from linir.idchr. during header reception, the parity bits are checked and can generate a lin identifier parity error (see section 24.6.10.13 ). bits 6 and 7 in linir.idchr read as zero when receiving. ? linmr.pardis=1: during header transmission, all the bits in linir.idchr are sent on the bus. during header reception, all the bits in linir.idchr are updated with the received identifier. 24.6.10.9 node action after an identifier transaction, a lin response mode must be selected. this is done in the node action field (linmr.nact). below are some response modes exemplified in a small lin cluster: ? response, from master to slave1: master: nact=publish slave1: nact=subscribe slave2: nact=ignore ? response, from slave1 to master: master: nact=subscribe slave1: nact=publish slave2: nact=ignore ? response, from slave1 to slave2: master: nact=ignore slave1: nact=publish slave2: nact=subscribe 4 ? +4 -1 +1 << ? () 100 48 2over ? () 1 + [] baudrate 8 15 ? 100 --------- - 1 + ?? ?? 1% ----------------------------------------------------------------------------------------------- ?? ?? ?? ?? ?? hz =
601 42023e?sam?07/2013 atsam4l8/l4/l2 24.6.10.10 lin response data length the response data length is the number of data fields (bytes), excluding the checksum. figure 24-32. response data length the response data length can be configured, either by the user, or automatically by bits 4 and 5 in the identifier (linir.idchr), in accordance to lin 1.1. the user selects one of these modes by writing to the data length mode bit (linmr.dlm): ? linmr.dlm=0: the response data length is configured by the user by writing to the 8-bit data length control field (linmr.dlc). the response data length equals dlc + 1 bytes. ? linmr.dlm=1: the response data length is defined by the identifier (linir.idchr) bits according to the table below. 24.6.10.11 checksum the last frame field is the checksum. it is configured by the checksum type (linmr.chktyp), and the checksum disable (linmr.chkdis) bits . csr.txrdy will not be set after the last thr data write if enabled. writing a one to linmr.chkdis will disa ble the automatic checksum gen- eration/checking, and the user may send/check this last byte manually, disguised as a normal data. the checksum is an inverted 8-bit sum with carry, either: ? over all data bytes, called a classic checksum. this is used for lin 1.3 compliant slaves, and automatically managed when chkdis=0, and chktyp=1. ? over all data bytes and the protected identifier, called an enhanced checksum. this is used for lin 2.0 compliant slaves, and automatically managed when chkdis=0, and chktyp=0. 24.6.10.12 frame slot mode a lin master can be configured to use frame slots with a pre-defined minimum length. this frame slot mode is enabled by default, and is di sabled by writing a one to the frame slot mode disable bit (linmr.fsdis). the frame slot mo de will not allow csr.txrdy to be set after a frame transfer until the entire frame slot duration has elapsed, in effect preventing the master from sending a new header. the li n transfer complete bit (csr.l intc) will still be set after the checksum has been sent. an interrup t is generated if the lin transf er complete bit in the inter- rupt mask register (imr.lintc) is set. writing a one to cr.rststa clears csr.lintc. user configuration: 1 - 256 data fields (dlc+1) identifier configuration: 2/4/8 data fields sync break sync field identifier field checksum field data field data field data field data field table 24-14. response data length if dlm = 1 linir.idchr[5] linir.idchr[4] re sponse data length [bytes] 00 2 01 2 10 4 11 8
602 42023e?sam?07/2013 atsam4l8/l4/l2 figure 24-33. frame slot mode with automatic checksum the minimum frame slot size is determined by tframe_maximum, and calculated below (all val- ues in bit periods): ? theader_nominal = 34 ? tframe_maximum = 1.4 x (theader_nominal + tresponse_nominal + 1) note: the term ?+1? leads to an integer re sult for tframe_max (lin specification 1.3) if the checksum is sent (chkdis=0): ? tresponse_nominal = 10 x (ndata + 1) ? tframe_maximum = 1.4 x (34 + 10 x (dlc + 1 + 1) + 1) ? tframe_maximum = 77 + 14 x dlc if the checksum is not sent (chkdis=1): ? tresponse_nominal = 10 x ndata ? tframe_maximum = 1.4 x (34 + 10 x (dlc + 1) + 1) ? tframe_maximum = 63 + 14 x dlc 24.6.10.13 lin errors this section describes the errors generated in lin mode, and the coresponding error bits in csr. the error bits are cleared by writing a on e to cr.rststa. an interrupt request is gener- ated if the corresponding bit in the interrupt mask re gister (imr) is set. this bit is set by writing a one to the corresponding bit in the interrupt enable register (ier). ? header time-out error (csr.linhte) ? this error is generated if the header is not received within the time specified by theader_maximum. ? sync tolerance error (csr.linste) ? this error is generated if the synchronization baudrate deviation is larger than the maximum tolerance, ftol_unsync 15%. the synchronization procedure is aborted. ? slave not responding error (csr.linsnre) break synch protected identifier data n checksum header inter- frame space response space frame frame slot = tframe_maximum response txrdy write thr write linid data 1 data 2 data 3 data3 data n-1 data n frame slot mode disabled frame slot mode enabled lintc data 1
603 42023e?sam?07/2013 atsam4l8/l4/l2 ? this error is generated if no valid message appears within the tframe_maximum time frame slot, while the usart is expecting a response from another node (nact=subscribe). ? checksum error (csr.lince) ? this error is generated if the received checksum is wrong. this error can only be generated if the checksum feature is enabled (chkdis=0). ? identifier parity error (csr.linipe) ? this error is generated if the identifier parity is wrong. this error can only be generated if parity is enabled (pardis=0). ? inconsistent sync field error (csr.linisfe) ? this error is generated in slave mode if the sync field character received is not 0x55. synchronization procedure is aborted. ? bit error (csr.linbe) ? this error is generated if the value transmitted by the usart on tx differs from the value sampled on rx. if a bit error is detected, the transmission is aborted at the next byte border. 24.6.11 lin frame handling 24.6.11.1 master node configuration ? configure the baud rate by writing to brgr.cd and brgr.fp ? configure the frame transfer by writing to the linmr fields nact, pardis, chkdis, chktype, dlm, fsdis, and dlc ? select lin mode and master node by writing 0xa to mr.mode ? write a one to cr.txen and cr.rxen to enable both transmitter and receiver ? wait until csr.txrdy is one ? send the header by wr iting to linir.idchr the following procedure depends on the linmr.nact setting: ? case 1: linmr.nact is 0x0 (publish, the usart transmits the response) ? wait until csr.txrdy is one ? send a byte by writing to thr.txchr ? repeat the two previous steps until there is no more data to send ? wait until csr.lintc is one ? check for lin errors ? case 2: linmr.nact is 0x1 (subscribe, the usart receives the response) ? wait until csr.rxrdy is one ? read rhr.rxchr ? repeat the two previous steps until there is no more data to read ? wait until csr.lintc is one ? check for lin errors ? case 3: linmr.nact is 0x2 (ignore, the usart is not concerned by a response) ? wait until csr.lintc is one ? check for lin errors
604 42023e?sam?07/2013 atsam4l8/l4/l2 figure 24-34. master node configuration, linmr.nact is 0x0 (publish) figure 24-35. master node configuration, linmr.nact is 0x1 (subscribe) frame break synch protected identifier data 1 data n checksum txrdy write thr write linir data 1 data 2 data 3 data n-1 data n rxrdy header inter- frame space response space frame slot = tframe_maximum response data3 lintc fsdis=1 fsdis=0 break synch protected identifier data 1 data n checksum txrdy read rhr write linir data 1 data n-1 data n-1 rxrdy data n data n-2 header inter- frame space response space frame frame slot = tframe_maximum response data3 lintc fsdis=0 fsdis=1
605 42023e?sam?07/2013 atsam4l8/l4/l2 figure 24-36. master node configuration, linmr.nact is 0x2 (ignore) 24.6.11.2 slave node configuration ? configure the baud rate by writing to brgr.cd and brgr.fp ? configure the frame transfer by writing to linmr fields nact, pardis, chkdis, chktype, dlm, and dlc ? select lin mode and slave node by writing 0xb to mr.mode ? write a one to cr.txen and cr.rxen to enable both transmitter and receiver ? wait until csr.linid is one ? check for csr.linisfe and csr. linpe errors, clear errors and csr.linid by writing a one to cr.rststa ? read linir.idchr important : if linmr.nact is 0x0 (publish), and this field is already correct, the linmr register must still be written with this value in order to set cs r.txrdy, and to request the corre- sponding peripheral dma controller write transfer. the different linmr.nact settings result in the same procedure as for the master node, see section 24.6.11.1 ?master node configuration? on page 603 . figure 24-37. slave node configuration, li nmr.nact is 0x0 (publish) txrdy write linir rxrdy lintc break synch protected identifier data 1 data n checksum data n-1 header inter- frame space response space frame frame slot = tframe_maximum response data3 fsdis=1 fsdis=0 break synch protected identifier data 1 data n checksum txrdy write thr read linid data 1 data 3 data n-1 data n rxrdy linidrx data 2 lintc
606 42023e?sam?07/2013 atsam4l8/l4/l2 figure 24-38. slave node configuration, li nmr.nact is 0x1 (subscribe) figure 24-39. slave node configuration, linmr.nact is 0x2 (ignore) 24.6.12 lin frame handling with the peripheral dma controller the usart can be used together with the peripheral dma controller in order to transfer data without processor intervention. the peripheral dma controller uses the csr.txrdy and csr.rxrdy bits to trigger one byte writes or reads. it always writes to thr, and it always reads rhr. 24.6.12.1 master node configuration the peripheral dma controller mode bit (linmr.pdcm ) allows the user to select configuration: ? linmr.pdcm=0: lin configuration must be writt en to linmr, it is no t stored in the write buffer. ? linmr.pdcm=1: lin configuratio n is written by the periphera l dma controller to thr, and is stored in the write buffer. since data transfer size is a byte, the transfer is split into two accesses. the first writes the nact, pardis, chkdis, chktyp, dlm and fsdis bits in the linmr register, while the seco nd writes the linmr.dlc fiel d. if linmr.nact=publish, the write buffer will also contain the identifier. when linmr.nact=subscribe, the read buffer contains the data. txrdy read rhr read linid rxrdy linidrx lintc break synch protected identifier data 1 data n checksum data 1 data n-1 data n-1 data n data n-2 txrdy read rhr read linid rxrdy linidrx lintc break synch protected identifier data 1 data n checksum data n-1
607 42023e?sam?07/2013 atsam4l8/l4/l2 figure 24-40. master node with peripheral dma controller (linmr.pdcm=0) figure 24-41. master node with peripheral dma controller (linmr.pdcm=1) 24.6.12.2 slave node configuration in this mode, the peripheral dma controller transfers only data. the user reads the identifier from linir, and selects lin mode by writing to linmr. when na ct=publish the data is in the write buffer, while the read buffer contains the data when nact=subscribe. important: if in slave mode, linmr.nact is already configur ed correctly as publish, the linmr register must still be wr itten with this value in order to set csr.txrdy, and to request the corresponding peripheral dma controller write transfer. | | | | rxrdy txrdy peripheral bus usart lin controller data 0 data n | | | | read buffer node action = publish node action = subscribe peripheral dma controller rxrdy peripheral bus data 0 data 1 data n write buffer peripheral dma controller usart lin controller | | | | | | | | nact pardis chkdis chktyp dlm fsdis dlc identifier data 0 data n write buffer rxrdy peripheral bus dlc identifier data 0 data n write buffer rxrdy read buffer node action = publish node action = subscribe peripheral dma controller peripheral dma controller usart lin controller nact pardis chkdis chktyp dlm fsdis usart lin controller txrdy peripheral bus
608 42023e?sam?07/2013 atsam4l8/l4/l2 figure 24-42. slave node with peripheral dma controller 24.6.13 wake-up request any node in a sleeping lin cluster may request a wake-up. by writing to the wakeup signal type bit (linmr.wkuptyp), the user can choose to send either a lin 1.3 (wkuptyp is one ) or a lin 2.0 (wkuptyp is zero) compliant wakeup request. writing a one to the send lin wakeup signal bit (cr.linwkup), transmits a wakeup, and when comple ted, sets csr.lintc. according to lin 1.3, the wakeup request should be generated with the character 0x80 in order to impose eight successive dominant bits. according to lin 2.0, the wakeup request is issued by forcing the bus into the dominant state for 250s to 5ms. sending the character 0xf0 does this, regardless of baud rate. ? baud rate max = 20 kbit/s -> one bit period = 50s -> five bit periods = 250s ? baud rate min = 1 kbit/s -> one bit period = 1ms -> five bit periods = 5ms 24.6.14 bus idle time-out lin bus inactivity should eventually cause slav es to time out and enter sleep mode. lin 1.3 specifies this to 25000 bit periods, whilst lin 2. 0 specifies 4 seconds. for the time-out counter operation see section 24.6.3.4 ?receiver time-out? on page 584 . 24.6.15 spi mode the usart features a serial peripheral interface (spi) link compliant mode, supporting syn- chronous, full-duplex communication in both master and slave mode. writing 0xe (master) or 0xf (slave) to mr.mode will enable this mode. an spi in master mode controls the data flow to and from the other spi devices, which are in slave mode. it is possible to let devices take turns being masters (aka multi-master protocol), and one master may shift data simultaneously into several slaves, but only one slave may respond at a time. a slave is selected when its slave | | | | | | | | data 0 data n rxrdy per ipheral bus read buffer nact = subscribe data 0 data n txrdy per ipheral bus write buffer usart lin controller usart lin controller peripheral dma controller peripheral dma controller table 24-15. receiver time-out values (rtor.to) lin specification baud rate time-out period to 2.0 1 000 bit/s 4s 4 000 2 400 bit/s 9 600 9 600 bit/s 38 400 19 200 bit/s 76 800 20 000 bit/s 80 000 1.3 - 25 000 bit periods 25 000
609 42023e?sam?07/2013 atsam4l8/l4/l2 select (nss) signal has been raised by the master. the usart can only generate one nss sig- nal, and it is possible to use standard i/o lines to address more than one slave. 24.6.15.1 modes of operation the spi system consists of two data lines and two control lines: ? master out slave in (mosi): this line supplies the data shifted from master to slave. in master mode this is connected to txd, and in slave mode to rxd. ? master in slave out (miso): this line supplies the data shifted from slave to master. in master mode this is connected to rxd, and in slave mode to txd. ? serial clock (clk): this is controlled by the master. one period per bit transmission. in both modes this is connected to clk. ? slave select (nss): this control line allows the master to select or deselect a slave. in master mode this is connected to rts, and in slave mode to cts. changing spi mode after initial configuration must be followed by a transceiver software reset in order to avoid unpredictable behavior. 24.6.15.2 baud rate the baud rate generator operates as described in ?baud rate in synchronous and spi mode? on page 588 , with the following requirements: in spi master mode: ? external clock clk must not be selected as clock (the clock selection field (mr.usclks) must not equal 0x3). ? the usart must drive the clk pin (mr.clko must be one). ? the brgr.cd field must be at least 0x4. ? if the internal divided clock, clk_usart/div, is selected (mr.usclks is one), the value in brgr.cd must be even, ensuring a 50:50 duty cycle. in spi slave mode: ? the frequency of the external clock clk must be at least four times lower than the system clock. 24.6.15.3 data transfer up to nine data bits are successively shifted out on the txd pin at each edge. there are no start, parity, or stop bits, and msb is always s ent first. the spi clock polarity (mr.cpol), and spi clock phase (mr.cpha) bits configure cl k by selecting the edges upon which bits are shifted and sampled, resulting in four non-interoperable protocol modes, see table 24-16 . if mr.cpol is zero, the inactive state value of clk is logic level zero, and if mr.cpol is one, the inactive state value of clk is lo gic level one. if mr.cpha is zero, data is changed on the lead- ing edge of clk, and captured on the following edge of clk. if mr.cpha is one, data is captured on the leading edge of clk, and changed on the following edge of clk. a mas-
610 42023e?sam?07/2013 atsam4l8/l4/l2 ter/slave pair must use the same configuration, and the master must be reconfigured if it is to communicate with slaves using different configurations. see figures 24-43 and 24-44 . figure 24-43. spi transfer format (cpha=1, 8 bits per transfer) figure 24-44. spi transfer format (cpha=0, 8 bits per transfer) table 24-16. spi bus protocol modes mr.cpol mr.cpha spi bus protocol mode 01 0 00 1 11 2 10 3 clk cycle (for reference) clk (cpol= 1) mosi spi master ->txd spi slave ->rxd miso spi master ->rxd spi slave ->txd nss spi master ->rts spi slave ->cts msb msb 1 clk (cpol= 0) 3 5 6 78 lsb 1 2 3 4 6 65 5 43 21 lsb 24 clk cycle (for reference) clk (cpol= 0) clk (cpol= 1) mosi spi master -> txd spi slave -> rxd miso spi master -> rxd spi slave -> txd nss spi master -> rts spi slave -> cts msb 6 5 msb 6 5 4 43 32 21 1 lsb lsb 8 7 6 5 4 3 2 1
611 42023e?sam?07/2013 atsam4l8/l4/l2 24.6.15.4 receiver and transmitter control see ?manchester encoder? on page 611 , and ?receiver status? on page 581 . 24.6.15.5 character transmission and reception when the inhibit non acknowledge bit in mr (mr.inack) is one , the spi master will not send pending thr values until csr.rxrdy is zero. in spi master mode, the slave select line (nss) is asserted low one bit period before the start of transmission, and released high one bit period after every character transmission. a delay for at least three bit periods is always inserted in between characters. in order to address slave de vices supporting the chip select active after transfer (csaat) mode, nss can be forced low by writing a one to the force spi chip select bit (cr.rtsen/fcs). rel easing nss when fcs is o ne is only possible by writing a one to the release spi chip select bit (cr.rtsdis/rcs). in spi slave mode, a low level on nss for at least one bit period will allow the slave to initiate a transmission or reception. the underrun error bi t (csr.unre) is set if a character must be sent while thr is empty, and txd will be high during character transmission , as if 0xff was being sent. an interrupt request is generated if the underrun error bit in the interrupt mask register (imr.unre) is set. if a new character is written to thr it will be sent correctly during the next transmission slot. writing a on e to cr.rststa will clear csr.unre. to ensure correct behav- ior of the receiver in spi slave mode, the master device sending the frame must ensure a minimum delay of one bit period in between each character transmission. 24.6.15.6 receiver time-out receiver time-outs are not possible in spi mode as the baud rate clock is only active during data transfers. 24.6.16 manchester encoder/decoder writing a one to the manchester encoder/decoder bit in the mode register (mr.man) enables the manchester encoder/decoder. when the manc hester encoder/decoder is used, characters transmitted through the usart are encoded in manchester ii biphase format. depending on polarity configuration, selected by the transm ission manchester polarity bit in the manchester configuration register (man.tx_mopl), a logic level (zero or one) is transmitted as the transi- tion from high -to-low or low-to-high during the middle of each bit period. this consumes twice the bandwidth of the simpler nrz coding schemes, but the receiver has more error control since the expected input has a transition at every mid-bit period. 24.6.16.1 manchester encoder an example of a manchester encoded sequence is the byte 0xb1 (10110001) being encoded to 10 01 10 10 01 01 01 10, assuming default encoder polarity. figure 24-45 illustrates this coding scheme. figure 24-45. nrz to manchester encoding a manchester encoded character can be prec eded by both a preamble sequence and a start frame delimiter. the preamble sequence is a pre-defined pattern with a configurable length from nrz encoded data manchester encoded data 10110001 txd
612 42023e?sam?07/2013 atsam4l8/l4/l2 1 to 15 bit periods. if the preamble length is zero, the preamble waveform is not generated. the preamble length is selected by writing to the transmitter preamble length field (man.tx_pl). the available preamble sequence patterns are: ? all_one ? all_zero ?one_zero ?zero_one and are selected by writing to the transmitter preamble pattern field (man.tx_pp). figure 24- 46 illustrates the supported patterns. figure 24-46. preamble patterns, default polarity assumed the start frame delimiter selector bit (mr.onebit) configures the manchester start bit pattern following the preamble. if mr.onebit is one, a manchester encoded zero is transmitted to indi- cate that a new character is about to be sent. if mr.onebit is zero, a synchronization pattern is sent for the duration of three bit periods to inaugurate the new character. the sync pattern wave- form by itself is an invalid manchester encoding , since the transition only occurs at the middle of the second bit period. the manchester synchronization mode bit (mr.mod sync) selects sync pattern, and this also defines if the character is data (modsync=0) with a zero to one transition, or a command (modsync=1) with a one to zero transition. when direct memory access is used, the sync pat- tern can be updated on-the-fly with a modified character located in memory. to enable this mode the variable synchronization of command/data sync start frame delimiter bit (mr.var_sync) must be written to one. in this case, modsync is bypassed and thr.txsynh selects the sync type to be included. figure 24-47 illustrates supp orted patterns. manchester encoded data txd sfd data 8 bit width "all_one" preamble manchester encoded data txd sfd data 8 bit width "all_zero" preamble manchester encoded data txd sfd data 8 bit width "zero_one" preamble manchester encoded data txd sfd data 8 bit width "one_zero" preamble
613 42023e?sam?07/2013 atsam4l8/l4/l2 figure 24-47. start frame delimiter manchester drift compensation the drift compensation bit (man.drift) enables a hardware drift compensation and recovery system that allows for sub-optimal clock drifts without further user intervention. drift compensa- tion is only available in 16x oversampling mode (mr.over is zero). if the rxd event is one 16 th clock cycle from the expected edge, it is consider ed as normal jitter and no corrective action will be taken. if the event is two to four 16 th ?s early, the current per iod will be shortened by a 16 th . if the event is two to three 16 th ?s after the expected edge, the curr ent period will be prolonged by a 16 th . figure 24-48. bit resynchronization 24.6.16.2 manchester decoder the manchester decoder can detect selectable preamble sequences and start frame delimiters. the receiver manchester polarity bit in the ?manchester configuration register? (man.rx_mpol) selects input stream polarity. the receiver preamble length field (man.rx_pl) specifies the length characterist ics of detectable preambles. if man.rx_pl is zero, the preamble pattern detection will be disabled. t he receiver preamble pattern field (man.rx_pp) selects the pattern to be detected. see figure 24-46 for available preamble pat- terns. figure 24-49 illustrates two types of manchest er preamble pattern mismatches. manchester encoded data txd sfd data one bit start frame delimiter preamble length is set to 0 manchester encoded data txd sfd data command sync start frame delimiter manchester encoded data txd sfd data data sync start frame delimiter rxd oversampling 16x clock sampling point expected edge tolerance synchro. jump sync jump synchro. error synchro. error
614 42023e?sam?07/2013 atsam4l8/l4/l2 the manchester endec uses the same start frame delimiter selector (mr.onebit) for both encoder and decoder. if on ebit is one, only a ma nchester encoded zero will be accepted as a valid start frame delimiter. if onebit is zero, a data or command sync pattern will be expected. the received sync bit in the receive holding register (rhr.rxsynh) will be zero if the last character received is a data sync, and a one if it is a command sync. figure 24-49. preamble pattern mismatch the receiver samples the rxd line in continuos bit period quarters, making the smallest time frame in which to assume a bit value three quarte rs. a start bit is assume d if rxd is zero during one of these quarters, see figure 24-50 . figure 24-50. asynchronous star t bit detection if a valid preamble pattern or start frame delimiter is detected, the receiver continues decoding with the same synchronization. if a non-valid preamble pattern or a start frame delimiter is detected, the receiver re-synchronizes at the next valid edge. when a valid start sequence has been detected, the decoded data is passed to the usart and the user will be notified of any incoming manchester encoding violations by the manchester error bit (csr.manerr). an inter- rupt request is generated if one of the manchester error bits in the interrupt mask register (imr.mane or imr.manea) is set. csr.manerr is cleared by writing a one to the reset sta- tus bits in the control register (cr.rststa). a violation occurs when there is no transition in the middle of a bit period. see figure 24-51 for an illustration of a violation causing the man- chester error bit to be set. manchester encoded data txd sfd data preamble length is set to 8 preamble mismatch invalid pattern preamble mismatch manchester coding error manchester encoded data txd 1234 sampling clock (16 x) start detection
615 42023e?sam?07/2013 atsam4l8/l4/l2 figure 24-51. manchester error 24.6.16.3 radio interface: manchester endec application this section describes low data rate, full duplex, dua l frequency, rf systems integrated with a manchester endec, that support ask an d/or fsk modulati on schemes. see figure 24-52 . figure 24-52. manchester encoded characters rf transmission to transmit downstream, encoded data is sent serially to the rf modulator and then through space to the rf receiver. to receive, another frequency carrier is used and the rf demodulator does a bit-checking search for valid patterns before it switches to a receiving mode and forwards data to the decoder. defining preambles to help distinguish between noise and valid data has to be done in conjunction with the rf module, and may sometimes be filtered away from the endec stream. using the ask modulation scheme, a one is transmitted as an rf signal at the down- stream frequency, while a zero is transmitted as no signal. see figure 24-53 . the fsk modulation scheme uses two different frequencies to transmit data. a one is sent as a signal on one frequency, and a zero on the other. see figure 24-54 . manchester encoded data txd sfd preamble length is set to 4 elementary character bit time manchester coding error detected sampling points preamble subpacket and start frame delimiter were successfully decoded entering usart character area lna vco rf filter demod control bi-dir line pa rf filter mod vco control manchester decoder manchester encoder usart receiver usart emitter ask/fsk upstream receiver ask/fsk downstream transmitter upstream emitter downstream receiver serial configuration interface fup frequency carrier fdown frequency carrier
616 42023e?sam?07/2013 atsam4l8/l4/l2 figure 24-53. ask modulator output figure 24-54. fsk modulator output 24.6.17 test modes the internal loopback feature enables on-board diagnostics, and allows the usart to operate in three different test modes, with reconfigured pin functionality, as shown below. 24.6.17.1 normal mode during normal operation, a receiver rxd pin is connected to a transmitter txd pin. figure 24-55. normal mode configuration 24.6.17.2 automatic echo mode automatic echo mode allows bit-by-bit retransmission. when a bit is received on the rxd pin, it is also sent to the txd pin, as shown in figure 24-56 . transmitter configuration has no effect. manchester encoded data default polarity unipolar output txd ask modulator output uptstream frequency f0 nrz stream 10 0 1 manchester encoded data default polarity unipolar output txd fsk modulator output uptstream frequencies [f0, f0+offset] nrz stream 10 0 1 receiver transmitter rxd txd
617 42023e?sam?07/2013 atsam4l8/l4/l2 figure 24-56. automatic echo mode configuration 24.6.17.3 local loopback mode local loopback mode c onnects the output of the transmitter directly to the input of the receiver, as shown in figure 24-57 . the txd and rxd pins are not used. the rxd pin has no effect on the receiver and the txd pin is continuously driven high, as in idle state. figure 24-57. local loopback mode configuration 24.6.17.4 remote loopback mode remote loopback mode connects the rxd pin to the txd pin, as shown in figure 24-58 . the transmitter and the receiver are disabled and have no effect. this mode allows bit-by-bit retransmission. figure 24-58. remote loopback mode configuration 24.6.18 interrupts receiver transmitter rxd txd receiver transmitter rxd txd 1 receiver transmitter rxd txd 1 manea 23 22 21 20 19 18 17 16 ? ? ? mane ctsic dcdic? dsric? riic? 15 14 13 12 11 10 9 8 lintc linid nack/linbk rxbuff ? iter/unre txempty timeout
618 42023e?sam?07/2013 atsam4l8/l4/l2 the usart has the following interrupt sources: ? linhte: lin header time-out error ? a lin header time-out error has been detected ? linste: lin sync tolerance error ? a lin sync tolerance error has been detected ? linsnre: lin slave not responding error ? a lin slave not responding error has been detected ? lince: lin checksum error ? a lin checksum error has been detected ? linipe: lin identifier parity error ? a lin identifier parity error has been detected ? linisfe: lin inconsistent sync field error ? the usart is configured as a slave node and a lin inconsistent sync field error has been detected since the last rststa. ? linbe: lin bit error ? a bit error has been detected since the last rststa. ? manerr: manchester error ? at least one manchester error has been detected since the last rststa. ? ctsic: clear to send input change flag ? at least one change has been detected on the cts pin since the last csr read. ? dcdic: data carrier detect input change flag ? a change has been detected on the dcd pin ? dsric: data set ready input change flag ? a change has been detected on the dsr pin ? riic: ring indicator input change flag ? a change has been detected on the ri pin ? lintc: lin transfer completed ? a lin transfer has been completed ? linidr: lin identifier ? a lin identifier has been sent (master) or received (slave) ? nack: non acknowledge ? at least one non acknowledge has been detected ? rxbuff: reception buffer full ? the buffer full signal from the peripheral dma controller channel is active. ? iter/unre: max number of repetitions reached or spi underrun error ? if usart does not operate in spi slave mode: maximum number of repetitions has been reached since the last rststa. 76543210 pare frame ovre ? ? rxbrk txrdy rxrdy
619 42023e?sam?07/2013 atsam4l8/l4/l2 ? if usart operates in spi slave mode: at least one spi underrun error has occurred since the last rststa. ? txempty: transmitter empty ? there are no characters in neither thr, nor in the transmit shift register. ? timeout: receiver time-out ? there has been a time-out since the last start time-out command. ? pare: parity error ? either at least one parity error has been detected, or the parity bit is a one in multidrop mode, since the last rststa. ? frame: framing error ? at least one stop bit has been found as low since the last rststa. ? ovre: overrun error ? at least one overrun error has occurred since the last rststa. ? rxbrk: break received/end of break ? break received or end of break detected since the last rststa. ? txrdy: transmitter ready ? there is no character in the thr. ? rxrdy: receiver ready ? at least one complete char acter has been received and rhr has not yet been read. an interrupt source will set a co rresponding bit in the channel status regist er (csr). the inter- rupt sources will generate an interrupt request if the corresponding bit in the interrupt mask register (imr) is set. the interrupt sources are ored together to form one interrupt request. the usart will generate an interrupt request if at least one of t he bits in imr is set. bits in imr are set by writing a one to the corresponding bit in the interrupt enable register (ier), and cleared by writing a one to the corresponding bit in the interrupt disable register (idr). the interrupt request remains active until the corresponding bit in csr is cleared. the clearing of the bits in csr is described in ?channel status register? on page 630 . because all the interrupt sources are ored together, the in terrupt request from the usart will remain active until all the bits in csr are cleared. 24.6.19 using the peripheral dma controller 24.6.20 write protection registers to prevent single software errors from corrupting usart behavior, certain address spaces can be write-protect ed by writing the correct wr ite protect key and writing a one to the write protect enable bit in the write protect mode regi ster (wpmr.wpkey and wp mr.wpen). disabling the write protection is done by writing the correct key to wpmr.wpkey and a zero to wpmr.wpen. write attempts to a write-protected register are detected and the write protect violation status bit in the write protect status register (wpsr.w pvs) is set. the write protect violation source field (wpsr.wpvsrc) indicates the target register. writing the co rrect key to th e write protect key bit (wpmr.wpkey) clears wpsr. wpvsrc and wpsr.wpvs. the protected registers are: ? ?mode register? on page 624
620 42023e?sam?07/2013 atsam4l8/l4/l2 ? ?baud rate generator register? on page 635 ? ?receiver time-out register? on page 637 ? ?transmitter timeguard register? on page 638 ? ?fi di ratio register? on page 639 ? ?irda filter register? on page 641 ? ?manchester configuration register? on page 642
621 42023e?sam?07/2013 atsam4l8/l4/l2 24.7 user interface note: 1. values in the version register vary wit h the version of the ip block implementation. table 24-17. usart register memory map offset register register name access reset 0x00 control register cr write-only 0x00000000 0x04 mode register mr read-write 0x00000000 0x08 interrupt enable register ier write-only 0x00000000 0x0c interrupt disable register idr write-only 0x00000000 0x010 interrupt mask register imr read-only 0x00000000 0x14 channel status register csr read-only 0x00000000 0x18 receiver holding register rhr read-only 0x00000000 0x1c transmitter holding register thr write-only 0x00000000 0x20 baud rate generator register brgr read-write 0x00000000 0x24 receiver time-out register rtor read-write 0x00000000 0x28 transmitter timeguard register ttgr read-write 0x00000000 0x40 fi di ratio regist er fidi read-write 0x00000174 0x44 number of errors register ner read-only 0x00000000 0x4c irda filter regist er ifr read-write 0x00000000 0x50 manchester configuration register man read-write 0x30011004 0x54 lin mode register linmr read-write 0x00000000 0x58 lin identifier register linir read-write 0x00000000 0x5c lin baud rate register linbr read-only 0x00000000 0xe4 write protect mode register wpmr read-write 0x00000000 0xe8 write protect status register wpsr read-only 0x00000000 0xfc version register version read-only - (1)
622 42023e?sam?07/2013 atsam4l8/l4/l2 24.7.1 control register name: cr access type: write-only offset: 0x00 reset value: 0x00000000 ? linwkup: send lin wakeup signal writing a zero to this bit has no effect. writing a one to this bit will send a wakeup signal on the lin bus. ? linabt: abort lin transmission writing a zero to this bit has no effect. writing a one to this bit will abort the current lin transmission. ? rtsdis/rcs: request to send disable/release spi chip select writing a zero to this bit has no effect. writing a one to this bit when usart is not in spi master mode drives rts high. writing a one to this bit when usart is in spi master mode releases nss (rts pin). ? rtsen/fcs: request to send enable/force spi chip select writing a zero to this bit has no effect. writing a one to this bit when usart is not in spi master mode drives rts low. writing a one to this bit when usart is in spi master mode forces nss (rts pin) low, even if usart is not transmitting, in order to address spi slave devices supporting the csaat mode (chip select active after transfer). ? dtrdis: data terminal ready disable writing a zero to this bit has no effect. writing a one to this bit drives dtr high. ? dtren: data terminal ready enable writing a zero to this bit has no effect. writing a one to this bit drives dtr low. ? retto: rearm time-out writing a zero to this bit has no effect. writing a one to this bit reloads the time-out counter and clears csr.timeout. ? rstnack: reset non acknowledge writing a zero to this bit has no effect. writing a one to this bit clears csr.nack. ? rstit: reset iterations writing a zero to this bit has no effect. writing a one to this bit clears csr.iter if iso7816 is enabled (mr.mode is 0x4 or 0x6) 31 30 29 28 27 26 25 24 ???????? 23 22 21 20 19 18 17 16 ? ? linwkup linabt rtsdis/rcs rtsen/fcs dtrdis? dtren? 15 14 13 12 11 10 9 8 retto rstnack rstit senda sttto stpbrk sttbrk rststa 76543210 txdis txen rxdis rxen rsttx rstrx ? ?
623 42023e?sam?07/2013 atsam4l8/l4/l2 ? senda: send address writing a zero to this bit has no effect. writing a one to this bit will in multidrop mode se nd the next character written to thr as an address. ? sttto: start time-out writing a zero to this bit has no effect. writing a one to this bit will abort any current time-out count down, and trigger a new count down when the next character has been received. csr.timeout is also cleared. ? stpbrk: stop break writing a zero to this bit has no effect. writing a one to this bit will stop the generation of break sign al characters, and then send ones for ttgr.tg duration, or at l east 12 bit periods. no effect if no break is being transmitted. ? sttbrk: start break writing a zero to this bit has no effect. writing a one to this bit will start transmission of break charac ters when current characters present in thr and the transmit s hift register have been sent. no effect if a break signal is already being generated. csr.txrdy and csr.txempty will be cleared. ? rststa: reset status bits writing a zero to this bit has no effect. writing a one to this bit will clear the following bits in csr: pare, frame, ovre, manerr, linhte, linste, linbe, linisfe, linipe, lince, linsnre, lintc, linid, unre, and rxbrk. ? txdis: transmitter disable writing a zero to this bit has no effect. writing a one to this bit disables the transmitter. ? txen: transmitter enable writing a zero to this bit has no effect. writing a one to this bit enables the transmitter if txdis is zero. ? rxdis: receiver disable writing a zero to this bit has no effect. writing a one to this bit disables the receiver. ? rxen: receiver enable writing a zero to this bit has no effect. writing a one to this bit enables the receiver if rxdis is zero. ? rsttx: reset transmitter writing a zero to this bit has no effect. writing a one to this bit will reset the transmitter. ? rstrx: reset receiver writing a zero to this bit has no effect. writing a one to this bit will reset the receiver.
624 42023e?sam?07/2013 atsam4l8/l4/l2 24.7.2 mode register name: mr access type: read-write offset: 0x04 reset value: 0x00000000 this register can only be written if write protection is disabled in the ?write protect mode register? (wpmr.wpen is zero). ? onebit: start frame delimiter selector 0: the start frame delimiter is a comma nd or data sync, as defined by modsync. 1: the start frame delimiter is a normal start bit, as defined by modsync. ? modsync: manchester synchronization mode 0: the manchester start bit is either a 0-to-1 transition, or a data sync. 1: the manchester start bit is either a 1-to-0 transition, or a command sync. ? man: manchester encoder/decoder enable 0: manchester endec is disabled. 1: manchester endec is enabled. ? filter: infrared receive line filter 0: the usart does not filter the receive line. 1: the usart filters the receive line by doing three consecutive samples and uses the majority value. ? max_iteration this field determines the number of acceptable consecutive nacks when in protocol t=0. ? invdata: inverted data 0: the txd and rxd transmissions equal the values written to thr and read from rhr. normal mode of operation. 1: the txd and rxd transmissions equal the xor?ed values wri tten to thr and read from rhr. inverted mode of operation, parity is accounted for. ? var_sync: variable synchronization of co mmand/data sync start frame delimiter 0: sync pattern according to modsync. 1: sync pattern according to thr.txsynh. ? dsnack: disable successive nack 0: nacks are handled as normal, unless disabled by inack. 1: the receiver restricts the amount of consecutive nacks by max_iteration value. if max_iteration=0 no nack will be issued and the first erroneous message is acce pted as a valid character, setting csr.iter. ? inack: inhibit non acknowledge 0: the nack is generated. in spi mast er mode, transmission is as usual. 1: the nack is not generated. in spi master mode, data in thr will not be sent until rxrdy is zero. ? over: oversampling mode 0: oversampling at 16 times the baud rate. 31 30 29 28 27 26 25 24 onebit modsync man filter ? max_iteration 23 22 21 20 19 18 17 16 invdata var_sync dsnack inack over clko mode9 msbf/cpol 15 14 13 12 11 10 9 8 chmode nbstop par sync/cpha 76543210 chrl usclks mode
625 42023e?sam?07/2013 atsam4l8/l4/l2 1: oversampling at 8 times the baud rate. ? clko: clock output select 0: the usart does not drive the clk pin. 1: the usart drives the clk pin unless usclks selects the external clock. ? mode9: 9-bit character length 0: chrl defines character length. 1: 9-bit character length. ? msbf/cpol: bit order or spi clock polarity if usart does not operate in spi mode: msbf=0: least significant bit is sent/received first. msbf=1: most significant bit is sent/received first. if usart operates in spi mode, cpol is used with cpha to produce the required clock/data relationship between devices. cpol=0: the inactive state value of clk is logic level zero. cpol=1: the inactive state value of clk is logic level one. ? chmode: channel mode ? nbstop: number of stop bits ? par: parity type ? sync/cpha: synchronous mode select or spi clock phase if usart does not operate in spi mode (m r.mode is not equal to 0xe or 0xf): sync = 0: usart operates in asynchronous mode. table 24-18. chmode mode description 0 0 normal mode 0 1 automatic echo. receiver input is connected to the txd pin. 1 0 local loopback. transmitter output is connected to the receiver input. 1 1 remote loopback. rxd pin is internally connected to the txd pin. table 24-19. nbstop asynchronous (sync=0) synchronous (sync=1) 0 0 1 stop bit 1 stop bit 0 1 1.5 stop bits reserved 1 0 2 stop bits 2 stop bits 1 1 reserved reserved table 24-20. par parity type 0 0 0 even parity 001odd parity 0 1 0 parity forced to 0 (space) 0 1 1 parity forced to 1 (mark) 1 0 x no parity 1 1 x multidrop mode
626 42023e?sam?07/2013 atsam4l8/l4/l2 sync = 1: usart operates in synchronous mode. if usart operates in spi mode, cpha determines which edge of clk causes data to change and which edge causes data to be captured. cpha is used with cpol to produce the requ ired clock/data relationship between master and slave devices. cpha = 0: data is changed on the leading edge of clk and captured on the following edge of clk. cpha = 1: data is captured on the leading edge of clk and changed on the following edge of clk. ? chrl: character length. ? usclks: clock selection note: 1. the value of div is device dependent. refer to the module configuration section at the end of this chapter. ?mode table 24-21. chrl character length 0 0 5 bits 0 1 6 bits 1 0 7 bits 1 1 8 bits table 24-22. usclks selected clock 0 0 clk_usart 0 1 clk_usart/div (1) 10reserved 11 clk table 24-23. mode mode of the usart 0000normal 0001rs485 0010hardware handshaking 0011modem 0100is 07816 protocol: t = 0 0110is 07816 protocol: t = 1 1000irda 1010lin master 1011lin slave 1110spi master 1111spi slave others reserved
627 42023e?sam?07/2013 atsam4l8/l4/l2 24.7.3 interrupt enable register name: ier access type: write-only offset: 0x08 reset value: 0x00000000 writing a zero to a bit in this register has no effect. writing a one to a bit in this register will set the corresponding bit in imr. ? linhte: lin header time-out error ? linste: lin sync tolerance error ? linsnre: lin slave not responding error ? lince: lin checksum error ? linipe: lin identi fier parity error ? linisfe: lin inconsistent sync field error ? linbe: lin bit error ? manea/mane: manchester error ? ctsic: clear to send input change flag ? dcdic: data carrier detect input change flag ? dsric: data set ready input change flag ? riic: ring indicator input change flag ? lintc: lin transfer completed ? linidr: lin identifier ? nack: non acknowledge ? rxbuff: reception buffer full ? iter/unre: max number of repetitions reached or spi underrun error ? txempty: transmitter empty ? timeout: receiver time-out ? pare: parity error ? frame: framing error ? ovre: overrun error ? rxbrk: break received/end of break ? txrdy: transmitter ready ? rxrdy: receiver ready for backward compatibility the mane bit has been duplicated to the manea bit position . writing either o ne or the other has the same effect. the corresponding bit in csr and the corresponding interrupt request are named manerr. 31 30 29 28 27 26 25 24 linhte linste linsnre lince li nipe linisfe linbe manea 23 22 21 20 19 18 17 16 ? ? ? mane ctsic dcdic? dsric? riic? 15 14 13 12 11 10 9 8 lintc linid nack/linbk rxbuff ? iter/unre txempty timeout 76543210 pare frame ovre ? ? rxbrk txrdy rxrdy
628 42023e?sam?07/2013 atsam4l8/l4/l2 24.7.4 interrupt disable register name: idr access type: write-only offset: 0x0c reset value: 0x00000000 writing a zero to a bit in this register has no effect. writing a one to a bit in this register will clear the corresponding bit in imr. ? linhte: lin header time-out error ? linste: lin sync tolerance error ? linsnre: lin slave not responding error ? lince: lin checksum error ? linipe: lin identi fier parity error ? linisfe: lin inconsistent sync field error ? linbe: lin bit error ? manea/mane: manchester error ? ctsic: clear to send input change flag ? dcdic: data carrier detect input change flag ? dsric: data set ready input change flag ? riic: ring indicator input change flag ? lintc: lin transfer completed ? linidr: lin identifier ? nack: non acknowledge ? rxbuff: reception buffer full ? iter/unre: max number of repetitions reached or spi underrun error ? txempty: transmitter empty ? timeout: receiver time-out ? pare: parity error ? frame: framing error ? ovre: overrun error ? rxbrk: break received/end of break ? txrdy: transmitter ready ? rxrdy: receiver ready for backward compatibility the mane bit has been duplicated to the manea bit position . writing either o ne or the other has the same effect. the corresponding bit in csr and the corresponding interrupt request are named manerr. 31 30 29 28 27 26 25 24 linhte linste linsnre lince li nipe linisfe linbe manea 23 22 21 20 19 18 17 16 ? ? ? mane ctsic dcdic? dsric? riic? 15 14 13 12 11 10 9 8 lintc linid nack/linbk rxbuff ? iter/unre txempty timeout 76543210 pare frame ovre ? ? rxbrk txrdy rxrdy
629 42023e?sam?07/2013 atsam4l8/l4/l2 24.7.5 interrupt mask register name: imr access type: read-only offset: 0x10 reset value: 0x00000000 0: the corresponding interrupt is disabled. 1: the corresponding interrupt is enabled. a bit in this register is cleared when the corresponding bit in idr is written to one. a bit in this register is set when the corresponding bit in ier is written to one. ? linhte: lin header time-out error ? linste: lin sync tolerance error ? linsnre: lin slave not responding error ? lince: lin checksum error ? linipe: lin identi fier parity error ? linisfe: lin inconsistent sync field error ? linbe: lin bit error ? manea/mane: manchester error ? ctsic: clear to send input change flag ? dcdic: data carrier detect input change flag ? dsric: data set ready input change flag ? riic: ring indicator input change flag ? lintc: lin transfer completed ? linidr: lin identifier ? nack: non acknowledge ? rxbuff: reception buffer full ? iter/unre: max number of repetitions reached or spi underrun error ? txempty: transmitter empty ? timeout: receiver time-out ? pare: parity error ? frame: framing error ? ovre: overrun error ? rxbrk: break received/end of break ? txrdy: transmitter ready ? rxrdy: receiver ready for backward compatibility the mane bit has been duplicated to the manea bit position. r eading either one or the other has the same effect. the corresponding bit in csr and the corresponding interrupt request are named manerr. 31 30 29 28 27 26 25 24 linhte linste linsnre lince li nipe linisfe linbe manea 23 22 21 20 19 18 17 16 ? ? ? mane ctsic dcdic? dsric? riic? 15 14 13 12 11 10 9 8 lintc linid nack/linbk rxbuff ? iter/unre txempty timeout 76543210 pare frame ovre ? ? rxbrk txrdy rxrdy
630 42023e?sam?07/2013 atsam4l8/l4/l2 24.7.6 channel status register name: csr access type: read-only offset: 0x14 reset value: 0x00000000 ? linhte: lin header time-out error 0: no lin header time-out error has been detected since the last rststa. 1: a lin header time-out error has been detected since the last rststa. this bit is cleared by writing a one to cr.rststa. ? linste: lin sync tolerance error 0: no lin sync tolerance error has been detected since the last rststa. 1: a lin sync tolerance error has been detected since the last rststa. this bit is cleared by writing a one to cr.rststa. ? linsnre: lin slave not responding error 0: no lin slave not responding error has been detected since the last rststa. 1: a lin slave not responding error has been detected since the last rststa. this bit is cleared by writing a one to cr.rststa. ? lince: lin checksum error 0: no lin checksum error has been detected since the last rststa. 1: a lin checksum error has been detected since the last rststa. this bit is cleared by writing a one to cr.rststa. ? linipe: lin identi fier parity error 0: no lin identifier parity error has been detected since the last rststa. 1: a lin identifier parity error has been detected since the last rststa. this bit is cleared by writing a one to cr.rststa. ? linisfe: lin inconsistent sync field error 0: no lin inconsistent sync field erro r has been detected since the last rststa 1: the usart is configured as a slave node and a lin inconsiste nt sync field error has been detected since the last rststa. this bit is cleared by writing a one to cr.rststa. ? linbe: lin bit error 0: no bit error has been detected since the last rststa. 1: a bit error has been detected since the last rststa. this bit is cleared by writing a one to cr.rststa. ? manerr: manchester error 0: no manchester error has been detected since the last rststa. 1: at least one manchester error has been detected since the last rststa. 31 30 29 28 27 26 25 24 linhte linste linsnre lince li nipe linisfe linbe manerr 23 22 21 20 19 18 17 16 cts/linbls dcd? dsr? ri? ct sic dcdic? dsric? riic? 15 14 13 12 11 10 9 8 lintc linid nack/linbk rxbuff ? iter/unre txempty timeout 76543210 pare frame ovre ? ? rxbrk txrdy rxrdy
631 42023e?sam?07/2013 atsam4l8/l4/l2 ? cts/linbls: image of cts input, or lin bus line status (when in lin mode) 0: cts or lin bus line is low. 1: cts or lin bus line is high. ? dcd: image of dcd input 0: dcd is low. 1: dcd is high. ? dsr: image of dsr input 0: dsr is low. 1: dsr is high. ? ri: image of ri input 0: ri is low. 1: ri is high. ? ctsic: clear to send input change flag 0: no change has been detected on the cts pin since the last csr read. 1: at least one change has been detected on the cts pin since the last csr read. this bit is cleared when reading csr. ? dcdic: data carrier detect input change flag 0: no change has been detected on the dcd pin since the last csr read. 1: at least one change has been detected on the dcd pin since the last csr read. this bit is cleared when reading csr. ? dsric: data set ready input change flag 0: no change has been detected on the dsr pin since the last csr read. 1: at least one change has been detected on the dsr pin since the last csr read. this bit is cleared when reading csr. ? riic: ring indicator input change flag 0: no change has been detected on t he ri pin since the last csr read. 1: at least one change has been detected on the ri pin since the last csr read. this bit is cleared when reading csr. ? lintc: lin transfer completed 0: the usart is either idle or a lin transfer is ongoing. 1: a lin transfer has been comp leted since the last rststa. this bit is cleared by writing a one to cr.rststa: ? linid: lin identifier 0: no lin identifier has been sent or received. 1: a lin identifier has been s ent (master) or received (slave), since the last rststa. this bit is cleared by writing a one to cr.rststa: ? nack: non acknowledge 0: no non acknowledge has been detected since the last rstnack. 1: at least one non acknowledge has been detected since the last rstnack. this bit is cleared by writing a one to cr.rstnack. ? rxbuff: reception buffer full 0: the buffer full signal from the peripheral dma controller channel is inactive. 1: the buffer full signal from the peripheral dma controller channel is active. ? iter/unre: max number of repetition s reached or spi underrun error if usart operates in spi slave mode: unre = 0: no spi underrun error has occurred since the last rststa. unre = 1: at least one spi underrun error has occurred since the last rststa. if usart does not operate in spi slave mode, no functionality is associated to unre. the bit will behave as iter if the usart is in iso7816 mode: iter = 0: maximum number of repetitions has not been reached since the last rststa. iter = 1: maximum number of repetitions has been reached since the last rststa. this bit is cleared by writing a one to cr.rststa.
632 42023e?sam?07/2013 atsam4l8/l4/l2 ? txempty: transmitter empty 0: the transmitter is either disabled or there are ch aracters in thr, or in the transmit shift register. 1: there are no characters in neither th r, nor in the transmit shift register. this bit is cleared by writing a one to cr.sttbrk. ? timeout: receiver time-out 0: there has not been a time-out since the last star t time-out command (cr.sttto), or rtor.to is zero. 1: there has been a time-out since the last start time-out command. this bit is cleared by writing a one to cr.sttto or cr.retto. ? pare: parity error 0: either no parity error has been detect ed, or the parity bit is a zero in multidrop mode, since the last rststa. 1: either at least one parity error has been detected, or the pa rity bit is a one in multidrop mode, since the last rststa. this bit is cleared by writing a one to cr.rststa. ? frame: framing error 0: no stop bit has been found as low since the last rststa. 1: at least one stop bit has been f ound as low since the last rststa. this bit is cleared by writing a one to cr.rststa. ? ovre: overrun error 0: no overrun error has occurred since the last rststa. 1: at least one overrun error has occurred since the last rststa. this bit is cleared by writing a one to cr.rststa. ? rxbrk: break received/end of break 0: no break received or end of break detected since the last rststa. 1: break received or end of break detected since the last rststa. this bit is cleared by writing a one to cr.rststa. ? txrdy: transmitter ready 0: the transmitter is either disabled, or a character in thr is waiting to be transferred to the transmit shift register, or an sttbrk command has been requested. as soon as the transmitter is enabled, txrdy is set. 1: there is no character in the thr. this bit is cleared by writing a one to cr.sttbrk. ? rxrdy: receiver ready 0: the receiver is either disabled, or no complete character has been received since the last read of rhr. if characters were being received when the receiver was disabled, rxrdy is set when the receiver is enabled. 1: at least one complete character has been received and rhr has not yet been read. this bit is cleared when the receive holding register (rhr) is read.
633 42023e?sam?07/2013 atsam4l8/l4/l2 24.7.7 receiver holding register name: rhr access type: read-only offset: 0x18 reset value: 0x00000000 reading this register will clear the csr.rxrdy bit. ? rxsynh: received sync 0: last character received is a data sync. 1: last character received is a command sync. ? rxchr: received character last received character. 31 30 29 28 27 26 25 24 ???????? 23 22 21 20 19 18 17 16 ???????? 15 14 13 12 11 10 9 8 rxsynh ??????rxchr[8] 76543210 rxchr[7:0]
634 42023e?sam?07/2013 atsam4l8/l4/l2 24.7.8 transmitter holding register name: thr access type: write-only offset: 0x1c reset value: 0x00000000 ? txsynh: sync field to be transmitted 0: if mr.varsync is one, the next character sent is enc oded as data, and the start frame delimiter is a data sync. 1: if mr.varsync is one, the next character sent is encoded as a command, and the start fram e delimiter is a command sync. ? txchr: character to be transmitted if txrdy is zero this field contains the next character to be transmitted. 31 30 29 28 27 26 25 24 ???????? 23 22 21 20 19 18 17 16 ???????? 15 14 13 12 11 10 9 8 txsynh ??????tx chr[8] 76543210 txchr[7:0]
635 42023e?sam?07/2013 atsam4l8/l4/l2 24.7.9 baud rate generator register name: brgr access type: read-write offset: 0x20 reset value: 0x00000000 this register can only be written if write protection is disabled in the ?write protect mode register? (wpmr.wpen is zero). ? fp: fractional part 0: fractional divider is disabled. 1 - 7: baud rate resolution, defined by fp x 1/8. ? cd: clock divider 31 30 29 28 27 26 25 24 ???????? 23 22 21 20 19 18 17 16 ????? fp 15 14 13 12 11 10 9 8 cd[15:8] 76543210 cd[7:0] table 24-24. baud rate in asynchro nous mode (mr.sync is 0) cd over = 0 over = 1 0 baud rate clock disabled 1 to 65535 table 24-25. baud rate in synchronous mode (mr.sync is 1) and spi mode(mr.mode is 0xe or 0xf) cd baud rate 0 baud rate clock disabled 1 to 65535 baud rate selected clock 16 cd ? --------------------------------------- - = baud rate selected clock 8cd ? --------------------------------------- - = baud rate selected clock cd --------------------------------------- - =
636 42023e?sam?07/2013 atsam4l8/l4/l2 table 24-26. baud rate in iso7816 mode cd baud rate 0 baud rate clock disabled 1 to 65535 baud rate selected clock fi_di_ratio cd ? ------------------------------------------------- =
637 42023e?sam?07/2013 atsam4l8/l4/l2 24.7.10 receiver time-out register name: rtor access type: read-write offset: 0x24 reset value: 0x00000000 this register can only be written if write protection is disabled in the ?write protect mode register? (wpmr.wpen is zero). ? to: time-out value 0: the receiver time-out is disabled. 1 - 131071: the receiver time-out is enabled and the time-out delay is to x bit period. note that the size of the to counter is device dependent, refer to the module configuration section. 31 30 29 28 27 26 25 24 ???????? 23 22 21 20 19 18 17 16 ???????to[16] 15 14 13 12 11 10 9 8 to[15:8] 76543210 to[7:0]
638 42023e?sam?07/2013 atsam4l8/l4/l2 24.7.11 transmitter timeguard register name: ttgr access type: read-write offset: 0x28 reset value: 0x00000000 this register can only be written if write protection is disabled in the ?write protect mode register? (wpmr.wpen is zero). ? tg: timeguard value 0: the transmitter timeguard is disabled. 1 - 255: the transmitter timeguard is enabled and the timeguard delay is tg bit periods. 31 30 29 28 27 26 25 24 ???????? 23 22 21 20 19 18 17 16 ???????? 15 14 13 12 11 10 9 8 ???????? 76543210 tg
639 42023e?sam?07/2013 atsam4l8/l4/l2 24.7.12 fi di ratio register name: fidi access type: read-write offset: 0x40 reset value: 0x00000174 this register can only be written if write protection is disabled in the ?write protect mode register? (wpmr.wpen is zero). ? fi_di_ratio: fi over di ratio value 0: if iso7816 mode is selected, the baud rate generator does not generate a signal. 1 - 2047: if iso7816 mode is selected, the baud rate is the clock provided on clk divided by fi_di_ratio. 31 30 29 28 27 26 25 24 ???????? 23 22 21 20 19 18 17 16 ???????? 15 14 13 12 11 10 9 8 ????? fi_di_ratio[10:8] 76543210 fi_di_ratio[7:0]
640 42023e?sam?07/2013 atsam4l8/l4/l2 24.7.13 number of errors register name: ner access type: read-only offset: 0x44 reset value: 0x00000000 ? nb_errors: number of errors total number of errors that occurred during an iso7816 transf er. this register is automatically cleared when read. 31 30 29 28 27 26 25 24 ???????? 23 22 21 20 19 18 17 16 ???????? 15 14 13 12 11 10 9 8 ???????? 76543210 nb_errors
641 42023e?sam?07/2013 atsam4l8/l4/l2 24.7.14 irda filter register name: ifr access type: read-write offset: 0x4c reset value: 0x00000000 this register can only be written if write protection is disabled in the ?write protect mode register? (wpmr.wpen is zero). ? irda_filter: irda filter configures the irda demodulator filter. 31 30 29 28 27 26 25 24 ???????? 23 22 21 20 19 18 17 16 ???????? 15 14 13 12 11 10 9 8 ???????? 76543210 irda_filter
642 42023e?sam?07/2013 atsam4l8/l4/l2 24.7.15 manchester configuration register name: man access type: read-write offset: 0x50 reset value: 0x30011004 this register can only be written if write protection is disabled in the ?write protect mode register? (wpmr.wpen is zero). ? drift: drift ccompensation 0: the usart can not recover from a clock drift. 1: the usart can recover from clock drift (only available in 16x oversampling mode). ? rx_mpol: receiver manchester polarity 0: zeroes are encoded as zero-to-one transitions, and ones are encoded as a one-to-zero transitions. 1: zeroes are encoded as one-to-zero transitions, an d ones are encoded as a zero-to-one transitions. ? rx_pp: receiver preamble pattern detected ? rx_pl: receiver preamble length 0: the receiver preamble pattern detection is disabled. 1 - 15: the detected preamble length is rx_pl bit periods. ? tx_mpol: transmitter manchester polarity 0: zeroes are encoded as zero-to-one transitions, and ones are encoded as a one-to-zero transitions. 1: zeroes are encoded as one-to-zero transitions, an d ones are encoded as a zero-to-one transitions. 31 30 29 28 27 26 25 24 ? drift 1 rx_mpol ? ? rx_pp 23 22 21 20 19 18 17 16 ???? rx_pl 15 14 13 12 11 10 9 8 ? ? ? tx_mpol ? ? tx_pp 76543210 ???? tx_pl table 24-27. rx_pp preamble pattern de fault polarity assumed (rx_mpol fi eld not set) 0 0 all_one 0 1 all_zero 10zero_one 11one_zero
643 42023e?sam?07/2013 atsam4l8/l4/l2 ? tx_pp: transmitter preamble pattern ? tx_pl: transmitte r preamble length 0: the transmitter preamble pattern generation is disabled. 1 - 15: the preamble length is tx_pl bit periods. table 24-28. tx_pp preamble pattern default polari ty assumed (tx_mpol field not set) 0 0 all_one 0 1 all_zero 10zero_one 11one_zero
644 42023e?sam?07/2013 atsam4l8/l4/l2 24.7.16 lin mode register name: linmr access type: read-write offset: 0x54 reset value: 0x00000000 ? syncdis: synchronization disable 0: lin slave synchronization is enabled. 1: lin slave synchronization is disabled. ? pdcm: peripheral dma controller mode 0: the lin mode register is not writ ten by the peripheral dma controller. 1: the lin mode register, except for this bit, is written by the peripheral dma controller. ? dlc: data length control 0 - 255: if dlm=0 this field defines the response data length to dlc+1 bytes. ? wkuptyp: wakeup signal type 0: writing a one to cr.linwkup will send a lin 2.0 wakeup signal. 1: writing a one to cr.linwkup will send a lin 1.3 wakeup signal. ? fsdis: frame slot mode disable 0: the frame slot mode is enabled. 1: the frame slot mode is disabled. ? dlm: data length mode 0: the response data length is defined by dlc. 1: the response data length is defined by bi ts 4 and 5 of the identifier (linir.idchr). ? chktyp: checksum type 0: lin 2.0 ?enhanced? checksum 1: lin 1.3 ?classic? checksum ? chkdis: checksum disable 0: checksum is automatically computed and sent when master, and checked when slave. 1: checksum is not computed and sent, nor checked. ? pardis: parity disable 0: identifier parity is automatically computed and sent when master, and checked when slave. 1: identifier parity is not computed and sent, nor checked. 31 30 29 28 27 26 25 24 ???????? 23 22 21 20 19 18 17 16 ??????sy ncdis pdcm 15 14 13 12 11 10 9 8 dlc 76543210 wkuptyp fsdis dlm chktyp chkdis pardis nact
645 42023e?sam?07/2013 atsam4l8/l4/l2 ? nact: lin node action table 24-29. nact mode description 0 0 publish: the usart transmits the response. 0 1 subscribe: the usart receives the response. 1 0 ignore: the usart does not transmit and does not receive the response. 11reserved
646 42023e?sam?07/2013 atsam4l8/l4/l2 24.7.17 lin identifier register name: linir access type: read-write or read-only offset: 0x58 reset value: 0x00000000 ? idchr: identifier character if usart is in lin master mode, the idchr field is read-write, and its value is the identifier character to be transmitted. if usart is in lin slave mode, the idchr field is read-only , and its value is the last received identifier character. 31 30 29 28 27 26 25 24 ???????? 23 22 21 20 19 18 17 16 ???????? 15 14 13 12 11 10 9 8 ???????? 76543210 idchr
647 42023e?sam?07/2013 atsam4l8/l4/l2 24.7.18 lin baud rate register name: linbrr access type: read-only offset: 0x5c reset value: 0x00000000 ? linfp: lin fractional part after synchronization ? lincd: lin clock divider after synchronization 31 30 29 28 27 26 25 24 ???????? 23 22 21 20 19 18 17 16 ????? linfp 15 14 13 12 11 10 9 8 lincd 76543210 lincd
648 42023e?sam?07/2013 atsam4l8/l4/l2 24.7.19 write protect mode register register name: wpmr access type: read-write offset: 0xe4 reset value: see table 24-17 ? wpkey: write protect key has to be written to 0x555341 (?usa? in ascii) in order to successf ully write wpen. this bit always reads as zero. writing the correct key to this field cl ears wpsr.wpvsrc and wpsr.wpvs. ? wpen: write protect enable 0: write protection disabled. 1: write protection enabled. protects the registers: ? ?mode register? on page 624 ? ?baud rate generator register? on page 635 ? ?receiver time-out register? on page 637 ? ?transmitter timeguard register? on page 638 ? ?fi di ratio register? on page 639 ? ?irda filter register? on page 641 ? ?manchester configuration register? on page 642 31 30 29 28 27 26 25 24 wpkey[23:16] 23 22 21 20 19 18 17 16 wpkey[15:8] 15 14 13 12 11 10 9 8 wpkey[7:0] 76543210 -------wpen
649 42023e?sam?07/2013 atsam4l8/l4/l2 24.7.20 write protect status register register name: wpsr access type: read-only offset: 0xe8 reset value: see table 24-17 ? wpvsrc: write protect violation source if wpvs is one, this field indicates which write-protected register was unsuccessfully written to, either by address offset or code. ? wpvs: write protect violation status 0: no write protect violation has occurred since the last wpsr read. 1: a write protect violation has occurred since the last wpsr read. note: reading wpsr automatically cl ears all fields. writing the correct key to wpsr.wpkey clears all fields. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 wpvsrc[15:8] 15 14 13 12 11 10 9 8 wpvsrc[7:0] 76543210 -------wpvs
650 42023e?sam?07/2013 atsam4l8/l4/l2 24.7.21 version register name: version access type: read-only offset: 0xfc reset value: - ?mfn reserved. no functionality associated. ? version version of the module. no functionality associated. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 ---- mfn 15 14 13 12 11 10 9 8 ---- version[11:8] 76543210 version[7:0]
651 42023e?sam?07/2013 atsam4l8/l4/l2 24.8 module configuration the specific configuration for each usart instance is listed in the following tables.the module bus clocks listed here are connected to the system bus clocks. refer to the power manager chapter for details. table 24-30. module configuration feature usart0 usart1 usart2 usart3 spi logic implemented implemented implemented implemented lin logic implemented not implemente d not implemented not implemented manchester logic implemented not impl emented not implemented not implemented irda logic implemented not implemen ted not implemented not implemented rs485 logic implemented not implemen ted not implemented not implemented fractional baudrate implemented implemented implemented implemented iso7816 implemented not implemente d not implemented not implemented div value for divided clk_usart8888 receiver time-out counter size (size of the rtor.to field) 17-bits 8-bits 8-bits 8-bits table 24-31. module clock name module name clock name usart0 clk_usart0 usart1 clk_usart1 usart2 clk_usart2 usart3 clk_usart3 table 24-32. register reset values register reset value version 0x00000602
652 42023e?sam?07/2013 atsam4l8/l4/l2 25. picopower uart (picouart) rev: 1.0.1.0 25.1 features ? ultra low power uart rx line with fixed format : ? 9600 bauds ? 1 start bit ? 8-bit data ? no parity bit ?1 stop bit ? use very low power 32khz or 1khz reference clock (internal rc or crystal) ? event system support and device wake-up source ? start bit detection ? full frame reception ? character recognition ? all low power modes supported included backup mode 25.2 overview the picopower uart peripheral provides a minima listic uart rx line feature in any of the low power modes including backup mode. it allows the device to be waken up from any of low-power modes by monitoring the rx line. it also able to generate an event to the peripheral event con- troller (pevc). the picouart is usually associated with anoth er usart in the system, sharing the same rxd pin. the picouart is then used to wake -up the device and the usart provides the full uart rx/tx feature when the device is waken up the number of picouart modules implemented is device specific. refer to the module config- uration section for details. 25.3 block diagram figure 25-1. picouart block diagram picouart rxd clk32 peripheral bus rhr rx_fsm wake bpm cfg cr clk_picouart pevc event
653 42023e?sam?07/2013 atsam4l8/l4/l2 25.4 i/o lines description 25.5 product dependencies in order to use this module, other parts of the system must be configured correctly, as described below. 25.5.1 i/o lines the picouart pin is directly connected to the rxd pin, meaning the user doesn?t need to con- figure the i/o controller to give control of the pin to the picouart. 25.5.2 power management picouart remains active when the system ente rs a power save mode that disables its clk_picouart clock. 25.5.3 clocks the configuration clock for picouart (clk_picouart) is generated by the power manager. it can be enabled or disabled either manually through the user interface of the power manager or automatically when the system enters a power save mode that disables the clocks to the peripheral bus modules. the running clock for picouart (clk32) is generated by the backup power manager and is necessary for the picouart to operate. the source of this clock can be either the rc32k or the osc32k, which must be enabled using the backup system control interface. 25.5.4 backup power management the picouart wake-up line is connected to th e backup power manager. it allows to wake-up the device from the current power save mode. the user must first configure the backup power manager to enable the wake-up source accordingly. 25.5.5 peripheral events the picouart peripheral events are connected via the peripheral event system. refer to the peripheral event system chapter for details. 25.6 functional description 25.6.1 reception operation picouart reception is enabled by writing a one to the rx enable bit in the control register (cr.rxen). picouart reception is disabled by writing a one to the rx disable bit in the con- trol register (cr.rxdis). reception is made by sampling the rxd pin on the clk32 reference clock. the decoding of the frame format is hardly coded and limited to the following configuration: ? 9600 bauds if clk32 is equal to 32,768 khz ? one start bit ? eight-bit data with lsb first table 25-1. i/o lines description pin name pin description type rxd receive serial data input
654 42023e?sam?07/2013 atsam4l8/l4/l2 ? one stop bit ? no parity bit a frame is valid when it matches exactly with this configuration. valid rece ived byte is extracted from the frame and stored in the receive hold ing register (rhr.cdata). when a valid data byte is stored, the data ready bit is set to one in the status register (sr.drdy). drdy is set to zero when a new start bit is detected. there is no overrun detection, meaning that rhr value is valid only when drdy is equal to one. 25.6.2 wakeup from power save mode picouart is able to wakeup the device fr om any power save mode including backup mode. the use should first enable the wakeup source by programming the configuration register (cfg.source) and select the source action to be a wake-up by programming the configura- tion register (cfg.action) . there are three wakeup sources: ? start bit detection: as soon as a start bit is detected , the picouart wakes up the device and normal picouart operations are perfomed, leading to drdy set to one if a valid frame is finally received. ? full frame reception: when a valid frame is re ceived, the valid received byte is stored in rhr and drdy is set to one. then the device is waken up ? character recognition: when a valid frame is received, the valid received byte is stored in rhr and drdy is set to one. if the received byte match the data stored in cfg.match, then the device is waken u.p only one wakeup source can be enabled at a time. 25.6.3 peripheral event picouart is able to generate an event to the pevc. the use should first enable the event source by programming the configuration register (cfg.source) and select the source action to be a wake-up by programming the configuration register (cfg.action) . there are three event sources: ? start bit detection: as soon as a start bit is detected , the picouart generates an event and normal picouart operations are perfomed, leading to drdy set to one if a valid frame is finally received. ? full frame reception: when a valid frame is re ceived, the valid received byte is stored in rhr and drdy is set to one. then the event is generated. ? character recognition: when a valid frame is received, the valid received byte is stored in rhr and drdy is set to one. if the received byte match the data stored in cfg.match, then the event is generated. only one even source can be enabled at a time.
655 42023e?sam?07/2013 atsam4l8/l4/l2 figure 25-2. frame valid waveform clk32 lsb msb rxd start bit detection full frame detection or character recognition sr.drdy
656 42023e?sam?07/2013 atsam4l8/l4/l2 25.7 user interface note: 1. the reset values for these registers are device specific. refer to the module configuration section at the end of this c hapter. table 25-2. picouart register memory map offset register register name access reset 0x00 control register cr write-only 0x00000000 0x04 configuration register cfg read/write 0x00000000 0x08 status register sr read-only 0x00000000 0x0c receive holding register rhr read 0x00000000 0x20 version register version read-only - (1)
657 42023e?sam?07/2013 atsam4l8/l4/l2 25.7.1 control register name: cr access type: write -only offset: 0x00 reset value: 0x00000000 ?dis: disable writing a zero to this bit has no effect. writing a one to this bit disables picouart. this bit always reads as zero. ? en: enable writing a zero to this bit has no effect. writing a one to this bit enables picouart. this bit always reads as zero. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 ------- - 15 14 13 12 11 10 9 8 - ------- 76543210 ------disen
658 42023e?sam?07/2013 atsam4l8/l4/l2 25.7.2 configuration register name: cfg access type: read/write offset: 0x04 reset value: 0x00000000 to avoid unexpected behavior cfg must be written when picouart is disabled. ? match: data match data used in characterer recognition, only used when source = 11. ? action: action to perform action to perform when source is not equal to 00. 0: wakeup the device. 1: generate an event. ? source: source enable mode 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 ------- - 15 14 13 12 11 10 9 8 match 76543210 - - - - - action source source mode 0 0 wake up and event disable 0 1 wake up or event enable on start bit detection 1 0 wake up or event enable on full frame reception 1 1 wake up or event enable on character recognition
659 42023e?sam?07/2013 atsam4l8/l4/l2 25.7.3 status register name: sr access type: read-only offset: 0x08 reset value: 0x00000000 ? drdy: data ready 0: no data is ready in rhr. 1: a new data is ready. this bit is cleared when a new start bit is detected. this bit is set when a valid frame is received. ? en: enable status 0: picouart is disabled. 1: picouart is enabled. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------- 76543210 ------drdyen
660 42023e?sam?07/2013 atsam4l8/l4/l2 25.7.4 receive holding register name: rhr access type: read/write offset: 0x0c reset value: 0x00000000 ? cdata: received data 31 30 29 28 27 26 25 24 --------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------- 76543210 cdata
661 42023e?sam?07/2013 atsam4l8/l4/l2 25.7.5 version register name: version access type: read-only offset: 0x20 reset value: - ? variant: variant number reserved. no functionality associated. ? version: version number version number of the module. no functionality associated. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 ---- variant 15 14 13 12 11 10 9 8 - - - - version[11:8] 76543210 version[7:0]
662 42023e?sam?07/2013 atsam4l8/l4/l2 25.8 module configuration the specific configuration for eac h picouart instance is listed in the following tables.the mod- ule bus clocks listed here are connected to the system bus clocks. refer to section 10. ?power manager (pm)? on page 108 for details. table 25-3. picouart clocks module name clock name description picouart clk_picouart peripheral clock for picouart table 25-4. picouart/usart association module name usart name description picouart usart0 usart instance a ssociated with picouart table 25-5. picouart rxd pin module name rxd pin number description picouart pb00 rxd pin number table 25-6. register reset values register reset value version 0x00000101
663 42023e?sam?07/2013 atsam4l8/l4/l2 26. serial peripheral interface (spi) rev: 2.1.1.3 26.1 features ? compatible with an embedded 32-bit microcontroller ? supports communication with serial external devices ? four chip selects with extern al decoder support allow co mmunication with up to 15 peripherals ? serial memories, such as da taflash and 3-wire eeproms ? serial peripherals, such as adcs, dacs, l cd controllers, can controllers and sensors ? external co-processors ? master or slave serial peripheral bus interface ? 4 - to 16-bit programmable da ta length per chip select ? programmable phase and polarity per chip select ? programmable transfer delays between consecutive transfers and between clock and data per chip select ? programmable delay between consecutive transfers ? selectable mode fault detection ? connection to peripheral dma controller ch annel capabilities opti mizes data transfers ? one channel for the receiver, one channel for the transmitter ? next buffer support ? four character fifo in reception 26.2 overview the serial peripheral interface (spi) circuit is a synchronous serial data link that provides com- munication with external devices in master or slave mode. it also enables communication between processors if an external processor is connected to the system. the serial peripheral interface is essentially a shift register that serially transmits data bits to other spis. during a data transfer, one spi syste m acts as the ?master?' which controls the data flow, while the other devices act as ?slaves'' whic h have data shifted into and out by the master. different cpus can take turn being masters (multiple master protocol opposite to single master protocol where one cpu is always the master while all of the others are always slaves) and one master may simultaneously shift da ta into multiple slaves. howeve r, only one slave may drive its output to write data back to the master at any given time. a slave device is selected when the master asse rts its nss signal. if multiple slave devices exist, the master generates a separate slav e select signal for each slave (npcs). the spi system consists of two data lines and two control lines: ? master out slave in (mosi): this data line supplies the output data from the master shifted into the input(s) of the slave(s). ? master in slave out (miso): this data line supplies the output data from a slave to the input of the master. there may be no more than one slave transmitting data during any particular transfer. ? serial clock (spck): this contro l line is driven by the master and regulates the flow of the data bits. the master may transmit data at a variety of baud rates; the spck line cycles once for each bit that is transmitted. ? slave select (nss): this control line allows slaves to be turned on and off by hardware.
664 42023e?sam?07/2013 atsam4l8/l4/l2 26.3 block diagram figure 26-1. spi block diagram 26.4 application block diagram figure 26-2. application block diagram: single master/multiple slave implementation spi interface interrupt control peripheral dma controller i/o controller clk_spi peripheral bus spi interrupt spck npcs3 npcs2 npcs1 npcs0/nss mosi miso slave 0 slave 2 slave 1 spck npcs3 npcs2 npcs1 npcs0 mosi miso spi master spck nss mosi miso spck nss mosi miso spck nss mosi miso nc
665 42023e?sam?07/2013 atsam4l8/l4/l2 26.5 i/o lines description 26.6 product dependencies in order to use this module, other parts of the system must be configured correctly, as described below. 26.6.1 i/o lines the pins used for interfacing the compliant external devices may be multiplexed with i/o lines. the user must first configure the i/o controll er to assign the spi pins to their peripheral functions. 26.6.2 clocks the clock for the spi bus interface (clk_spi) is generated by the power manager. this clock is disabled at reset, and can be enabled in the power manager. it is recommended to disable the spi before disabling the clock, to avoid freezing the spi in an undefined state. 26.6.3 interrupts the spi interrupt request line is connected to the nvic. using the spi interrupt requires the nvic to be programmed first. 26.7 functional description 26.7.1 modes of operation the spi operates in master mode or in slave mode. operation in master mode is configured by writing a one to the master/slave mode bit in the mode register (mr.mstr). the pins npcs0 to npcs3 are all configured as outputs, the spck pin is driven, the miso line is wired on the rece iver input and the mosi line driven as an output by the transmitter. if the mr.mstr bit is written to zero, the spi ope rates in slave mode. the miso line is driven by the transmitter output, the mosi line is wired on the receiver input, the spck pin is driven by the transmitter to synchronize the receiver. the npcs0 pin becomes an input, and is used as a slave select signal (nss). the pins npcs1 to npcs3 are not driven and can be used for other purposes. the data transfers are identically programmable for both modes of operations. the baud rate generator is activated only in master mode. table 26-1. i/o lines description pin name pin description type master slave miso master in slave out input output mosi master out slave in output input spck serial clock output input npcs1-npcs3 peripheral chip selects output unused npcs0/nss peripheral chip select/slave select output input
666 42023e?sam?07/2013 atsam4l8/l4/l2 26.7.2 data transfer four combinations of polarity and phase are available for data transfers. the clock polarity is configured with the clock polarity bit in the chip select registers (csrn.cpol). the clock phase is configured with the clock phase bit in the csrn registers (csrn.ncpha). these two bits determine the edges of the clock signal on which data is driven and sampled. each of the two bits has two possible states, resulting in four possible combinations that are incompatible with one another. thus, a master/slave pair must use the same parameter pair values to com- municate. if multiple slaves are used and fix ed in different configurations, the master must reconfigure itself each time it needs to communicate with a different slave. table 26-2 on page 666 shows the four modes and corresponding parameter settings. figure 26-3 on page 666 and figure 26-4 on page 667 show examples of data transfers. figure 26-3. spi transfer format (ncpha = 1, 8 bits per transfer) table 26-2. spi modes spi mode cpol ncpha 001 100 211 310 14 3 2 58 7 6 spck cycle (for reference) spck (cpol = 0) nss (to slave) miso (from slave) mosi (from master) spck (cpol = 1) msb 6 4 5lsb 1 2 3 msb 6 *** lsb 1 2 3 4 5 *** not defined, but normaly msb of previous c haracter received
667 42023e?sam?07/2013 atsam4l8/l4/l2 figure 26-4. spi transfer format (ncpha = 0, 8 bits per transfer) 26.7.3 master mode operations when configured in master mode, the spi uses the internal programmable baud rate generator as clock source. it fully controls the data transfers to and from the slave(s) connected to the spi bus. the spi drives the chip select line to the slave and the serial clock signal (spck). the spi features two holding registers, the tr ansmit data register (tdr) and the receive data register (rdr), and a single shi ft register. the holding registers maintain the data flow at a constant rate. after enabling the spi, a data transfer begins when the processor writes to the tdr register. the written data is immediately transferred in the shift register and transfer on the spi bus starts. while the data in the shift register is shifted on the mosi line, the miso line is sampled and shifted in the shift register. transmission cannot occur without reception. before writing to the tdr, the peripheral chip select field in tdr (tdr.pcs) must be written in order to select a slave. if new data is written to tdr during the transfer, it stays in it until the current transfer is com- pleted. then, the received data is transferred from the shift register to rdr, the data in tdr is loaded in the shift register and a new transfer starts. the transfer of a data written in tdr in the shift register is indicated by the transmit data reg- ister empty bit in the status register (sr.tdre). when new data is written in tdr, this bit is cleared. the sr.tdre bit is used to trigger the transmit peripheral dma controller channel. the end of transfer is indicated by the transmission registers empty bit in the sr register (sr.txempty). if a transfer delay (csrn.dlybct) is greater than zero for the last transfer, sr.txempty is set after the completion of said delay. the clk_spi can be switched off at this time. during reception, received data are transferred from the shift register to the reception fifo. the fifo can contain up to 4 characters (both receive data and peripheral chip select fields). while a character of the fifo is unread, the receive data register full bit in sr remains high (sr.rdrf). characters are read through the rdr re gister. if the four char acters stored in the fifo are not read and if a new character is stored, this sets the overrun error status bit in the sr register (sr.ovres). the procedure to follow in such a case is described in section 26.7.3.8 . 14 3 2 58 7 6 spck cycle (for reference) spck (cpol = 0) nss (to slave) miso (from slave) mosi (from master) spck (cpol = 1) msb 6 4 5lsb 1 2 3 6 lsb 1 2 3 4 5 *** not defined, but normaly lsb of previous character transmitted msb ***
668 42023e?sam?07/2013 atsam4l8/l4/l2 figure 26-5 on page 668 shows a block diagram of the spi when operating in master mode. fig- ure 26-6 on page 669 shows a flow chart describing how transfers are handled. 26.7.3.1 master mode block diagram figure 26-5. master mode block diagram baud rate generator rxfifoen 4 ? character fifo shift register tdre rxfifoen 4 ? character fifo ps pcsdec current peripheral modf modfdis mstr scbr csr0..3 csr0..3 cpol ncpha bits rdr rd rdrf ovres td tdr rdr csaat csnaat csr0..3 pcs mr pcs tdr spck clk_spi miso mosi msb lsb npcs1 npcs2 npcs3 npcs0 spi clock 0 1 0 1 0 1 npcs0
669 42023e?sam?07/2013 atsam4l8/l4/l2 26.7.3.2 master mode flow diagram figure 26-6. master mode flow diagram spi enable csaat ? ps ? 1 0 0 1 1 npcs = tdr(pcs) npcs = mr(pcs) delay dlybs serializer = tdr(td) tdre = 1 data transfer rdr(rd) = serializer rdrf = 1 tdre ? npcs = 0xf delay dlybcs fixed peripheral variable peripheral delay dlybct 0 1 csaat ? 0 tdre ? 1 0 ps ? 0 1 tdr(pcs) = npcs ? no yes mr(pcs) = npcs ? no npcs = 0xf delay dlybcs npcs = tdr(pcs) npcs = 0xf delay dlybcs npcs = mr(pcs), tdr(pcs) fixed peripheral variable peripheral - npcs defines the current chip select - csaat, dlybs, dlybct refer to the fields of the chip select register corresponding to the current chip select - when npcs is 0xf, csaat is 0.
670 42023e?sam?07/2013 atsam4l8/l4/l2 26.7.3.3 clock generation the spi baud rate clock is generated by dividing the clk_spi , by a value between 1 and 255. this allows a maximum operating baud rate at up to clk_spi and a minimum operating baud rate of clk_spi divided by 255. writing the serial clock baud rate field in the csrn registers (csrn.scbr) to zero is forbid- den. triggering a transfer while csrn.scbr is zero can lead to unpredictable results. at reset, csrn.scbr is zero and the user has to configure it at a valid value before performing the first transfer. the divisor can be defined independently for each chip select, as it has to be configured in the csrn.scbr field. this allows the spi to au tomatically adapt the baud rate for each interfaced peripheral without reprogramming. 26.7.3.4 transfer delays figure 26-7 on page 670 shows a chip select transfer change and consecutive transfers on the same chip select. three delays can be configured to modify the transfer waveforms: ? the delay between chip selects, programmable only once for all the chip selects by writing to the delay between chip selects field in the mr register (mr. dlybcs). allows insertion of a delay between release of one chip select and before assertion of a new one. ? the delay before spck, independently programmable for each chip select by writing the delay before spck field in the csrn register s (csrn.dlybs). allows the start of spck to be delayed after the chip select has been asserted. ? the delay between consecutive transfers, independently programmable for each chip select by writing the delay between consecutive transfers field in the csrn registers (csrn.dlybct). allows insertion of a delay be tween two transfers occurring on the same chip select these delays allow the spi to be adapted to the interfaced peripherals and their speed and bus release time. figure 26-7. programmable delays dlybcs dlybs dlybct dlybct chip select 1 chip select 2 spck
671 42023e?sam?07/2013 atsam4l8/l4/l2 26.7.3.5 peripheral selection the serial peripherals are selected through the assertion of the npcs0 to npcs3 signals. by default, all the npcs signals are high before and after each transfer. the peripheral selection can be performed in two different ways: ? fixed peripheral select: spi exchanges data with only one peripheral ? variable peripheral select: data can be exchanged with more than one peripheral fixed peripheral select is activated by writing a ze ro to the peripheral select bit in mr (mr.ps). in this case, the current peripheral is defined by the mr.pcs field and the tdr.pcs field has no effect. variable peripheral select is activated by writing a one to the mr.ps bit . the tdr.pcs field is used to select the current peripheral. this means that the peripheral selection can be defined for each new data. the fixed peripheral selection allows buffer transfers with a single peripheral. using the periph- eral dma controller is an optimal means, as the size of the data transfer between the memory and the spi is either 4 bits or 16 bits. however, changing the peripheral selection requires the mode register to be reprogrammed. the variable peripheral selection allows buffer transfers with multiple peripherals without repro- gramming the mr register. data written to tdr is 32-bits wide and defines the real data to be transmitted and the peripheral it is destined to. using the peripheral dma controller in this mode requires 32-bit wide buffers, with the data in the lsbs and the pcs and lastxfer fields in the msbs, however the spi still controls the number of bits (8 to16) to be transferr ed through miso and mosi lines with the csrn registers. this is not the optimal means in term of memory size for the buffers, but it provides a very effective means to exchange data with several peripherals without any intervention of the processor. 26.7.3.6 peripheral chip select decoding the user can configure the spi to operate with up to 15 peripherals by decoding the four chip select lines, npcs0 to npcs3 with an external logic. this can be enabled by writing a one to the chip select decode bit in the mr register (mr.pcsdec). when operating without decoding, the spi makes sure that in any case only one chip select line is activated, i.e. driven low at a time. if two bits are defined low in a pcs field, only the lowest numbered chip select is driven low. when operating with decoding, the spi directly outputs the value defined by the pcs field of either the mr register or the tdr register (depending on ps). as the spi sets a default value of 0xf on the chip select lines (i.e. all chip select lines at one) when not processing any transfer, only 15 peripherals can be decoded. the spi has only four chip select registers, not 15. as a result, when decoding is activated, each chip select defines the characteristics of up to four peripherals. as an example, the crs0 register defines the characteristics of the exter nally decoded peripherals 0 to 3, corresponding to the pcs values 0x0 to 0x3. thus, the user has to make sure to connect compatible peripherals on the decoded chip select lines 0 to 3, 4 to 7, 8 to 11 and 12 to 14. 26.7.3.7 peripheral deselection when operating normally, as soon as the transfer of the last data written in tdr is completed, the npcs lines all rise. this might lead to runtime error if the processor is too long in responding
672 42023e?sam?07/2013 atsam4l8/l4/l2 to an interrupt, and thus might lead to difficulties for interfacing with some serial peripherals requiring the chip select li ne to remain active during a full set of transfers. to facilitate interfacing with such devices, the csrn registers can be configur ed with the chip select active after transfer bit written to one (csrn.csaat) . this allows the chip select lines to remain in their current state (low = active) until transfer to another peripheral is required. when the csrn.csaat bit is written to qero, the npcs does not rise in all cases between two transfers on the same peripheral. during a transfe r on a chip select, the sr.tdre bit rises as soon as the content of the tdr is transferred into the internal shifter. when this bit is detected the tdr can be reloaded. if this reload occurs before the end of the current transfer and if the next transfer is performed on the same chip select as the current transfer, the chip select is not de-asserted between the two transfers. this migh t lead to difficulties fo r interfacing with some serial peripherals requiring the chip select to be de-asserted after each transfer. to facilitate interfacing with such devices, the csrn register s can be configured with the chip select not active after transfer bit (csrn.csnaat) written to one. this allows to de-assert systematically the chip select lines during a time dlybcs. (the value of th e csrn.csnaat bit is taken into account only if the csrn.csaat bit is written to zero for the same chip select). figure 26-8 on page 673 shows different peripheral deselection cases and the effect of the csrn.csaat and csrn.csnaat bits. 26.7.3.8 fifo management a fifo has been implemented in reception fifo (both in master and in slave mode), in order to be able to store up to 4 characters without causing an overrun error. if an attempt is made to store a fifth character, an overrun error rises. if such an event occurs, the fifo must be flushed. there are two ways to flush the fifo: ? by performing four read accesses of the rdr (the data read must be ignored) ? by writing a one to the flush fifo command bit in the cr register (cr.flushfifo). after that, the spi is able to receive new data.
673 42023e?sam?07/2013 atsam4l8/l4/l2 figure 26-8. peripheral deselection figure 26-8 on page 673 shows different peripheral deselection cases and the effect of the csrn.csaat and csrn.csnaat bits. 26.7.3.9 mode fault detection the spi is capable of detecting a mode fault when it is configured in master mode and npcs0, mosi, miso, and spck are configured as open dr ain through the i/o controller with either internal or external pullup resistors. if t he i/o controller does not have open-drain capability, mode fault detection must be disabled by writing a one to the mode fault detection bit in the mr a npcs[0..3] write tdr tdre npcs[0..3] write tdr tdre npcs[0..3] write tdr tdre dlybcs pcs = a dlybcs dlybct a pcs = b b dlybcs pcs = a dlybcs dlybct a pcs = b b dlybcs dlybct pcs=a a dlybcs dlybct a pcs = a a a dlybct aa csaat = 0 and csnaat = 0 dlybct aa csaat = 1 and csnaat= 0 / 1 a dlybcs pcs = a dlybct aa csaat = 0 and csnaat = 1 npcs[0..3] write tdr tdre pcs = a dlybct aa csaat = 0 and csnaat = 0
674 42023e?sam?07/2013 atsam4l8/l4/l2 register (mr.modfdis). in systems with open-drain i/o lines, a mode fault is detected when a low level is driven by an external master on the npcs0/nss signal. when a mode fault is detected, the mode fault error bit in the sr (sr.modf) is set until the sr is read and the spi is automatically disabled until re-enabled by writing a one to the spi enable bit in the cr register (cr.spien). by default, the mode fault detection circuitry is enabled. the user can disable mode fault detec- tion by writing a one to the mode fault dete ction bit in the mr re gister (mr.modfdis). 26.7.4 spi slave mode when operating in slave mode, the spi processes data bits on the clock provided on the spi clock pin (spck). the spi waits for nss to go active before receiving the serial clock from an external master. when nss falls, the clock is validated on the serializer, which processes the number of bits defined by the bits per transfer field of the chip select register 0 (csr0.bits). these bits are processed following a phase and a polarity defined respectively by the csr0.ncpha and csr0.cpol bits. note that the bits, cpol, and ncp ha bits of the other chip select registers have no effect when the spi is configured in slave mode. the bits are shifted out on the miso line and sampled on the mosi line. when all the bits are processed, the received data is transferred in the receive data register and the sr.rdrf bit rises. if the rdr register has not been read before new data is received, the sr.ovres bit is set. data is loaded in rdr even if this flag is set. th e user has to read the sr register to clear the sr.ovres bit. when a transfer starts, the data shifted out is the data present in the shift register. if no data has been written in the tdr register, the last data received is transferred. if no data has been received since the last reset, all bits are transmi tted low, as the shift register resets to zero. when a first data is written in tdr, it is trans ferred immediately in the shift register and the sr.tdre bit rises. if new data is written, it rema ins in tdr until a transfer occurs, i.e. nss falls and there is a valid clock on the spck pin. w hen the transfer occurs, the last data written in tdr is transferred in the shift register and the sr.tdre bit rises. this enables frequent updates of critical variables with single transfers. then, a new data is loaded in the shift register from the tdr. in case no character is ready to be transmitted, i.e. no character has been written in tdr since the last load from tdr to the shift register, the shift register is not modified and the last received character is retransmitted. in this case the underrun error status bit is set in sr (sr.undes). figure 26-9 on page 675 shows a block diagram of the spi when operating in slave mode.
675 42023e?sam?07/2013 atsam4l8/l4/l2 figure 26-9. slave mode functional block diagram shift register spck spiens lsb msb nss mosi spi clock tdre tdr td rdrf ovres csr0 cpol ncpha bits spien spidis miso undes rdr rd 4 - character fifo 0 1 rxfifoen
676 42023e?sam?07/2013 atsam4l8/l4/l2 26.8 user interface note: 1. the reset values are device specific. refer to th e module configuration section at the end of this chapter. table 26-3. spi register memory map offset register register name access reset 0x00 control register cr write-only 0x00000000 0x04 mode register mr read/write 0x00000000 0x08 receive data register rdr read-only 0x00000000 0x0c transmit data register tdr write-only 0x00000000 0x10 status register sr read-only 0x00000000 0x14 interrupt enable register ier write-only 0x00000000 0x18 interrupt disable register idr write-only 0x00000000 0x1c interrupt mask register imr read-only 0x00000000 0x30 chip select register 0 csr0 read/write 0x00000000 0x34 chip select register 1 csr1 read/write 0x00000000 0x38 chip select register 2 csr2 read/write 0x00000000 0x3c chip select register 3 csr3 read/write 0x00000000 0xe4 write protection control register wpcr read/write 0x00000000 0xe8 write protection status register wpsr read-only 0x00000000 0xf8 features register features read-only - (1) 0xfc version register version read-only - (1)
677 42023e?sam?07/2013 atsam4l8/l4/l2 26.8.1 control register name: cr access type: write-only offset: 0x00 reset value: 0x00000000 ? lastxfer: last transfer 1: the current npcs will be deasserted after the character wr itten in td has been transferred. when csrn.csaat is one, this allows to close the communication with the current serial peri pheral by raising the corresponding npcs line as soon as td transfer has completed. 0: writing a zero to this bit has no effect. ? flushfifo: flush fifo command 1: if the fifo mode is enabled (mr.fifoen written to one) and if an overrun error has been detected, this command allows to empty the fifo. 0: writing a zero to this bit has no effect. ? swrst: spi software reset 1: writing a one to this bit will reset the spi. a software-trigger ed hardware reset of the spi interface is performed. the spi is in slave mode after software reset. peripheral dma controller channels are not affected by software reset. 0: writing a zero to this bit has no effect. ? spidis: spi disable 1: writing a one to this bit will disable the spi. as soon as spi dis is written to one, the spi finishes its transfer, all pins are set in input mode and no data is received or transmitted. if a transfe r is in progress, the transfer is finished before the spi is disabled. if both spien and spidis are equal to one when the cr register is written, the spi is disabled. 0: writing a zero to this bit has no effect. ? spien: spi enable 1: writing a one to this bit will enable the spi to transfer and receive data. 0: writing a zero to this bit has no effect. 31 30 29 28 27 26 25 24 -------lastxfer 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------flushfifo 76543210 swrst - - - - - spidis spien
678 42023e?sam?07/2013 atsam4l8/l4/l2 26.8.2 mode register name: mr access type: read/write offset: 0x04 reset value: 0x00000000 ? dlybcs: delay between chip selects this field defines the delay from npcs inactive to the activation of another npcs. the dlybcs time guarantees non- overlapping chip selects and solves bus contentions in case of peripherals having long data float times. if dlybcs is less than or equal to six, six clk_spi periods will be inserted by default. otherwise, the following equation determines the delay: ? pcs: peripheral chip select this field is only used if fixed peripheral select is active (ps = 0). if pcsdec = 0: pcs = xxx0npcs[3:0] = 1110 pcs = xx01npcs[3:0] = 1101 pcs = x011npcs[3:0] = 1011 pcs = 0111npcs[3:0] = 0111 pcs = 1111forbidden (no peripheral is selected) (x = don?t care) if pcsdec = 1: npcs[3:0] output signals = pcs. ? llb: local loopback enable 1: local loopback path enabled. llb controls the local loopback on the data serializer for testing in master mode only (miso is internally connected on mosi). 0: local loopback path disabled. ? rxfifoen: fifo in reception enable 1: the fifo is used in reception (f our characters can be stored in the spi). 31 30 29 28 27 26 25 24 dlybcs 23 22 21 20 19 18 17 16 ---- pcs 15 14 13 12 11 10 9 8 -------- 76543210 llb rxfifoen - modf dis - pcsdec ps mstr delay between chip selects dlybcs clkspi ---------------------- - =
679 42023e?sam?07/2013 atsam4l8/l4/l2 0: the fifo is not used in reception (onl y one character can be stored in the spi). ? modfdis: mode fault detection 1: mode fault detection is disabled. if the i/o controller does not have o pen-drain capability, mode fault detection must be disabled for proper operation of the spi. 0: mode fault detection is enabled. ? pcsdec: chip select decode 0: the chip selects are directly connected to a peripheral device. 1: the four chip select lines are co nnected to a 4- to 16-bit decoder. when pcsdec equals one, up to 15 chip select signals can be generated with the four lines using an external 4- to 16-bit decoder. the csrn registers define the characteristics of the 15 chip selects according to the following rules: csr0 defines peripheral chip select signals 0 to 3. csr1 defines peripheral chip select signals 4 to 7. csr2 defines peripheral chip select signals 8 to 11. csr3 defines peripheral chip select signals 12 to 14. ? ps: peripheral select 1: variable peripheral select. 0: fixed peripheral select. ? mstr: master/slave mode 1: spi is in master mode. 0: spi is in slave mode.
680 42023e?sam?07/2013 atsam4l8/l4/l2 26.8.3 receive data register name: rdr access type: read-only offset: 0x08 reset value: 0x00000000 ? rd: receive data data received by the spi interface is stored in this register right-justified. unused bits read zero. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 rd[15:8] 76543210 rd[7:0]
681 42023e?sam?07/2013 atsam4l8/l4/l2 26.8.4 transmit data register name: tdr access type: write-only offset: 0x0c reset value: 0x00000000 ? lastxfer: last transfer 1: the current npcs will be deasserted after the character wr itten in td has been transferred. when csrn.csaat is one, this allows to close the communication with the current serial peri pheral by raising the corresponding npcs line as soon as td transfer has completed. 0: writing a zero to this bit has no effect. this field is only used if variable peripheral select is active (mr.ps = 1). ? pcs: peripheral chip select if pcsdec = 0: pcs = xxx0npcs[3:0] = 1110 pcs = xx01npcs[3:0] = 1101 pcs = x011npcs[3:0] = 1011 pcs = 0111npcs[3:0] = 0111 pcs = 1111forbidden (no peripheral is selected) (x = don?t care) if pcsdec = 1: npcs[3:0] output signals = pcs this field is only used if variable peripheral select is active (mr.ps = 1). ? td: transmit data data to be transmitted by the spi interface is stored in this re gister. information to be transmitted must be written to the td r register in a right-justified format. 31 30 29 28 27 26 25 24 -------lastxfer 23 22 21 20 19 18 17 16 ---- pcs 15 14 13 12 11 10 9 8 td[15:8] 76543210 td[7:0]
682 42023e?sam?07/2013 atsam4l8/l4/l2 26.8.5 status register name: sr access type: read-only offset: 0x10 reset value: 0x00000000 ? spiens: spi enable status 1: this bit is set when the spi is enabled. 0: this bit is cleared when the spi is disabled. ? undes: underrun error st atus (slave mode only) 1: this bit is set when a transfer begins whereas no data has been loaded in the tdr register. 0: this bit is cleared when the sr register is read. ? txempty: transmission registers empty 1: this bit is set when tdr and internal shifter are empty. if a transfer delay has been defined, txempty is set after the completion of such delay. 0: this bit is cleared as soon as data is written in tdr. ? nssr: nss rising 1: a rising edge occurred on nss pin since last read. 0: this bit is cleared when the sr register is read. ? ovres: overrun error status 1: this bit is set when an overrun has occurred. an overrun occu rs when rdr is loaded at least twice from the serializer since the last read of the rdr. 0: this bit is cleared when the sr register is read. ? modf: mode fault error 1: this bit is set when a mode fault occurred. 0: this bit is cleared when the sr register is read. ? tdre: transmit data register empty 1: this bit is set when the last data written in the tdr register has been transferred to the serializer. 0: this bit is cleared when data has been written to tdr and not yet transferred to the serializer. tdre equals zero when the spi is disabled or at re set. the spi enable command sets this bit to one. ? rdrf: receive data register full 1: data has been received and the received data has been transferr ed from the serializer to rdr since the last read of rdr. 0: no data has been received since the last read of rdr 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------spiens 15 14 13 12 11 10 9 8 - - - - - undes txempty nssr 76543210 - - - - ovres modf tdre rdrf
683 42023e?sam?07/2013 atsam4l8/l4/l2 26.8.6 interrupt enable register name: ier access type: write-only offset: 0x14 reset value: 0x00000000 writing a zero to a bit in this register has no effect. writing a one to a bit in this register will set the corresponding bit in imr. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 - - - - - undes txempty nssr 76543210 - - - - ovres modf tdre rdrf
684 42023e?sam?07/2013 atsam4l8/l4/l2 26.8.7 interrupt disable register name: idr access type: write-only offset: 0x18 reset value: 0x00000000 writing a zero to a bit in this register has no effect. writing a one to a bit in this register will clear the corresponding bit in imr. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 - - - - - undes txempty nssr 76543210 - - - - ovres modf tdre rdrf
685 42023e?sam?07/2013 atsam4l8/l4/l2 26.8.8 interrupt mask register name: imr access type: read-only offset: 0x1c reset value: 0x00000000 0: the corresponding interrupt is disabled. 1: the corresponding interrupt is enabled. a bit in this register is cleared when the corresponding bit in idr is written to one. a bit in this register is set when the corresponding bit in ier is written to one. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 - - - - - undes txempty nssr 76543210 - - - - ovres modf tdre rdrf
686 42023e?sam?07/2013 atsam4l8/l4/l2 26.8.9 chip select register 0 name: csr0 access type: read/write offset: 0x30 reset value: 0x00000000 ? dlybct: delay between consecutive transfers this field defines the delay between two consecutive transfers wi th the same peripheral without removing the chip select. the delay is always inserted after each transfer and before removing the chip select if needed. when dlybct equals zero, no delay between consecutive transfers is inserted and the clock keeps its duty cycle over the character transfers. otherwise, the following equation determines the delay: ? dlybs: delay before spck this field defines the delay from npcs valid to the first valid spck transition. when dlybs equals zero, the npcs valid to spck transition is 1/2 the spck clock period. otherwise, the following equat ions determine the delay: ? scbr: serial clock baud rate in master mode, the spi interface uses a modulus counter to de rive the spck baud rate from the clk_spi. the baud rate is selected by writing a value from 1 to 255 in the scbr field. the following equations determine the spck baud rate: writing the scbr field to zero is forbidden. triggering a transfer while scbr is zero can lead to unpredictable results. at reset, scbr is zero and the user has to write it to a valid value before performing the first transfer. if a clock divider (scbrn) field is set to one and the other scbr fields differ from one, access on csn is correct but no corre ct access will be possible on other cs. 31 30 29 28 27 26 25 24 dlybct 23 22 21 20 19 18 17 16 dlybs 15 14 13 12 11 10 9 8 scbr 76543210 bits csaat csnaat ncpha cpol delay between consecutive transfers 32 dlybct clkspi ------------------------------------ = delay before spck dlybs clkspi --------------------- = spck baudrate clkspi scbr --------------------- =
687 42023e?sam?07/2013 atsam4l8/l4/l2 ? bits: bits per transfer the bits field determines the number of data bits transferred. reserved values should not be used. ? csaat: chip select active after transfer 1: the peripheral chip select does not ri se after the last transfer is achieved. it remains active until a new transfer is requ ested on a different chip select. 0: the peripheral chip select line rises as soon as the last transfer is achieved. ? csnaat: chip select not active afte r transfer (ignored if csaat = 1) 0: the peripheral chip select does not rise between two transfers if the tdr is reloaded before the end of the first transfer a nd if the two transfers occur on the same chip select. 1: the peripheral chip select rises system atically between each transfe r performed on the same slave for a minimal duration of: (if dlybct field is different from 0) (if dlybct field equals 0) ? ncpha: clock phase 1: data is captured after the leading (inactive-to-active) e dge of spck and changed on the trailing (active-to-inactive) edge o f spck. 0: data is changed on the leading (inactive-to-active) edge of spck and captured after the trailing (active-to-inactive) edge o f spck. ncpha determines which edge of spck causes data to change and which edge causes data to be captured. ncpha is used with cpol to produce the requir ed clock/data relationship between master and slave devices. ?cpol: clock polarity 1: the inactive state value of spck is logic level one. 0: the inactive state value of spck is logic level zero. bits bits per transfer 0000 8 0001 9 0010 10 0011 11 0100 12 0101 13 0110 14 0111 15 1000 16 1001 4 1010 5 1011 6 1100 7 1101 reserved 1110 reserved 1111 reserved dlybcs clkspi ---------------------- - dlybcs 1 + clkspi -------------------------------- -
688 42023e?sam?07/2013 atsam4l8/l4/l2 cpol is used to determine the inactive state value of the seri al clock (spck). it is used wit h ncpha to produce the required clock/data relationship between master and slave devices.
689 42023e?sam?07/2013 atsam4l8/l4/l2 26.8.10 chip select register 1 name: csr1 access type: read/write offset: 0x34 reset value: 0x00000000 ? dlybct: delay between consecutive transfers this field defines the delay between two consecutive transfers wi th the same peripheral without removing the chip select. the delay is always inserted after each transfer and before removing the chip select if needed. when dlybct equals zero, no delay between consecutive transfers is inserted and the clock keeps its duty cycle over the character transfers. otherwise, the following equation determines the delay: ? dlybs: delay before spck this field defines the delay from npcs valid to the first valid spck transition. when dlybs equals zero, the npcs valid to spck transition is 1/2 the spck clock period. otherwise, the following equat ions determine the delay: ? scbr: serial clock baud rate in master mode, the spi interface uses a modulus counter to de rive the spck baud rate from the clk_spi. the baud rate is selected by writing a value from 1 to 255 in the scbr field. the following equations determine the spck baud rate: writing the scbr field to zero is forbidden. triggering a transfer while scbr is zero can lead to unpredictable results. at reset, scbr is zero and the user has to write it to a valid value before performing the first transfer. if a clock divider (scbrn) field is set to one and the other scbr fields differ from one, access on csn is correct but no corre ct access will be possible on other cs. 31 30 29 28 27 26 25 24 dlybct 23 22 21 20 19 18 17 16 dlybs 15 14 13 12 11 10 9 8 scbr 76543210 bits csaat csnaat ncpha cpol delay between consecutive transfers 32 dlybct clkspi ------------------------------------ = delay before spck dlybs clkspi --------------------- = spck baudrate clkspi scbr --------------------- =
690 42023e?sam?07/2013 atsam4l8/l4/l2 ? bits: bits per transfer the bits field determines the number of data bits transferred. reserved values should not be used. ? csaat: chip select active after transfer 1: the peripheral chip select does not ri se after the last transfer is achieved. it remains active until a new transfer is requ ested on a different chip select. 0: the peripheral chip select line rises as soon as the last transfer is achieved. ? csnaat: chip select not active afte r transfer (ignored if csaat = 1) 0: the peripheral chip select does not rise between two transfers if the tdr is reloaded before the end of the first transfer a nd if the two transfers occur on the same chip select. 1: the peripheral chip select rises system atically between each transfe r performed on the same slave for a minimal duration of: (if dlybct field is different from 0) (if dlybct field equals 0) ? ncpha: clock phase 1: data is captured after the leading (inactive-to-active) e dge of spck and changed on the trailing (active-to-inactive) edge o f spck. 0: data is changed on the leading (inactive-to-active) edge of spck and captured after the trailing (active-to-inactive) edge o f spck. ncpha determines which edge of spck causes data to change and which edge causes data to be captured. ncpha is used with cpol to produce the requir ed clock/data relationship between master and slave devices. ?cpol: clock polarity 1: the inactive state value of spck is logic level one. 0: the inactive state value of spck is logic level zero. bits bits per transfer 0000 8 0001 9 0010 10 0011 11 0100 12 0101 13 0110 14 0111 15 1000 16 1001 4 1010 5 1011 6 1100 7 1101 reserved 1110 reserved 1111 reserved dlybcs clkspi ---------------------- - dlybcs 1 + clkspi -------------------------------- -
691 42023e?sam?07/2013 atsam4l8/l4/l2 cpol is used to determine the inactive state value of the seri al clock (spck). it is used wit h ncpha to produce the required clock/data relationship between master and slave devices.
692 42023e?sam?07/2013 atsam4l8/l4/l2 26.8.11 chip select register 2 name: csr2 access type: read/write offset: 0x38 reset value: 0x00000000 ? dlybct: delay between consecutive transfers this field defines the delay between two consecutive transfers wi th the same peripheral without removing the chip select. the delay is always inserted after each transfer and before removing the chip select if needed. when dlybct equals zero, no delay between consecutive transfers is inserted and the clock keeps its duty cycle over the character transfers. otherwise, the following equation determines the delay: ? dlybs: delay before spck this field defines the delay from npcs valid to the first valid spck transition. when dlybs equals zero, the npcs valid to spck transition is 1/2 the spck clock period. otherwise, the following equat ions determine the delay: ? scbr: serial clock baud rate in master mode, the spi interface uses a modulus counter to de rive the spck baud rate from the clk_spi. the baud rate is selected by writing a value from 1 to 255 in the scbr field. the following equations determine the spck baud rate: writing the scbr field to zero is forbidden. triggering a transfer while scbr is zero can lead to unpredictable results. at reset, scbr is zero and the user has to write it to a valid value before performing the first transfer. if a clock divider (scbrn) field is set to one and the other scbr fields differ from one, access on csn is correct but no corre ct access will be possible on other cs. 31 30 29 28 27 26 25 24 dlybct 23 22 21 20 19 18 17 16 dlybs 15 14 13 12 11 10 9 8 scbr 76543210 bits csaat csnaat ncpha cpol delay between consecutive transfers 32 dlybct clkspi ------------------------------------ = delay before spck dlybs clkspi --------------------- = spck baudrate clkspi scbr --------------------- =
693 42023e?sam?07/2013 atsam4l8/l4/l2 ? bits: bits per transfer the bits field determines the number of data bits transferred. reserved values should not be used. ? csaat: chip select active after transfer 1: the peripheral chip select does not ri se after the last transfer is achieved. it remains active until a new transfer is requ ested on a different chip select. 0: the peripheral chip select line rises as soon as the last transfer is achieved. ? csnaat: chip select not active afte r transfer (ignored if csaat = 1) 0: the peripheral chip select does not rise between two transfers if the tdr is reloaded before the end of the first transfer a nd if the two transfers occur on the same chip select. 1: the peripheral chip select rises system atically between each transfe r performed on the same slave for a minimal duration of: (if dlybct field is different from 0) (if dlybct field equals 0) ? ncpha: clock phase 1: data is captured after the leading (inactive-to-active) e dge of spck and changed on the trailing (active-to-inactive) edge o f spck. 0: data is changed on the leading (inactive-to-active) edge of spck and captured after the trailing (active-to-inactive) edge o f spck. ncpha determines which edge of spck causes data to change and which edge causes data to be captured. ncpha is used with cpol to produce the requir ed clock/data relationship between master and slave devices. ?cpol: clock polarity 1: the inactive state value of spck is logic level one. 0: the inactive state value of spck is logic level zero. bits bits per transfer 0000 8 0001 9 0010 10 0011 11 0100 12 0101 13 0110 14 0111 15 1000 16 1001 4 1010 5 1011 6 1100 7 1101 reserved 1110 reserved 1111 reserved dlybcs clkspi ---------------------- - dlybcs 1 + clkspi -------------------------------- -
694 42023e?sam?07/2013 atsam4l8/l4/l2 cpol is used to determine the inactive state value of the seri al clock (spck). it is used wit h ncpha to produce the required clock/data relationship between master and slave devices.
695 42023e?sam?07/2013 atsam4l8/l4/l2 26.8.12 chip select register 3 name: csr3 access type: read/write offset: 0x3c reset value: 0x00000000 ? dlybct: delay between consecutive transfers this field defines the delay between two consecutive transfers wi th the same peripheral without removing the chip select. the delay is always inserted after each transfer and before removing the chip select if needed. when dlybct equals zero, no delay between consecutive transfers is inserted and the clock keeps its duty cycle over the character transfers. otherwise, the following equation determines the delay: ? dlybs: delay before spck this field defines the delay from npcs valid to the first valid spck transition. when dlybs equals zero, the npcs valid to spck transition is 1/2 the spck clock period. otherwise, the following equat ions determine the delay: ? scbr: serial clock baud rate in master mode, the spi interface uses a modulus counter to de rive the spck baud rate from the clk_spi. the baud rate is selected by writing a value from 1 to 255 in the scbr field. the following equations determine the spck baud rate: writing the scbr field to zero is forbidden. triggering a transfer while scbr is zero can lead to unpredictable results. at reset, scbr is zero and the user has to write it to a valid value before performing the first transfer. if a clock divider (scbrn) field is set to one and the other scbr fields differ from one, access on csn is correct but no corre ct access will be possible on other cs. 31 30 29 28 27 26 25 24 dlybct 23 22 21 20 19 18 17 16 dlybs 15 14 13 12 11 10 9 8 scbr 76543210 bits csaat csnaat ncpha cpol delay between consecutive transfers 32 dlybct clkspi ------------------------------------ = delay before spck dlybs clkspi --------------------- = spck baudrate clkspi scbr --------------------- =
696 42023e?sam?07/2013 atsam4l8/l4/l2 ? bits: bits per transfer the bits field determines the number of data bits transferred. reserved values should not be used. ? csaat: chip select active after transfer 1: the peripheral chip select does not ri se after the last transfer is achieved. it remains active until a new transfer is requ ested on a different chip select. 0: the peripheral chip select line rises as soon as the last transfer is achieved. ? csnaat: chip select not active afte r transfer (ignored if csaat = 1) 0: the peripheral chip select does not rise between two transfers if the tdr is reloaded before the end of the first transfer a nd if the two transfers occur on the same chip select. 1: the peripheral chip select rises system atically between each transfe r performed on the same slave for a minimal duration of: (if dlybct field is different from 0) (if dlybct field equals 0) ? ncpha: clock phase 1: data is captured after the leading (inactive-to-active) e dge of spck and changed on the trailing (active-to-inactive) edge o f spck. 0: data is changed on the leading (inactive-to-active) edge of spck and captured after the trailing (active-to-inactive) edge o f spck. ncpha determines which edge of spck causes data to change and which edge causes data to be captured. ncpha is used with cpol to produce the requir ed clock/data relationship between master and slave devices. ?cpol: clock polarity 1: the inactive state value of spck is logic level one. 0: the inactive state value of spck is logic level zero. bits bits per transfer 0000 8 0001 9 0010 10 0011 11 0100 12 0101 13 0110 14 0111 15 1000 16 1001 4 1010 5 1011 6 1100 7 1101 reserved 1110 reserved 1111 reserved dlybcs clkspi ---------------------- - dlybcs 1 + clkspi -------------------------------- -
697 42023e?sam?07/2013 atsam4l8/l4/l2 cpol is used to determine the inactive state value of the seri al clock (spck). it is used wit h ncpha to produce the required clock/data relationship between master and slave devices.
698 42023e?sam?07/2013 atsam4l8/l4/l2 26.8.13 write protection control register register name: wpcr access type: read-write offset: 0xe4 reset value: 0x00000000 ? spiwpkey: spi write protection key password if a value is written in spiwpen, the value is taken into acc ount only if spiwpkey is written wit h ?spi? (spi written in ascii code, i.e. 0x535049 in hexadecimal). ? spiwpen: spi write protection enable 1: the write protection is enabled. 0: the write protection is disabled. 31 30 29 28 27 26 25 24 spiwpkey[23:16] 23 22 21 20 19 18 17 16 spiwpkey[15:8] 15 14 13 12 11 10 9 8 spiwpkey[7:0] 76543210 -------spiwpen
699 42023e?sam?07/2013 atsam4l8/l4/l2 26.8.14 write protection status register register name: wpsr access type: read-only offset: 0xe8 reset value: 0x00000000 ? spiwpvsrc: spi write protection violation source this field indicates the peripheral bus offset of th e register concerned by the violation (mr or csrx) ? spiwpvs: spi write prot ection violation status 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 spiwpvsrc 76543210 - - - - - spiwpvs spiwpvs value violation type 1 the write protection has blocked a write access to a protected register (since the last read). 2 software reset has been performed while write protection was enabled (since the last read or since the last write acce ss on mr, ier, idr or csrx). 3 both write protection violation and software reset with write protection enabled have occurred since the last read. 4 write accesses have been detected on mr (while a chip select was active) or on csri (while the chip select ?i? was active) since the last read. 5 the write protection has blocked a write acce ss to a protected register and write accesses have been detected on mr (while a chip select was active) or on csri (while the chip select ?i? was active) since the last read. 6 software reset has been performed while write protection was enabled (since the last read or since the last write access on mr, ier, idr or csrx) and some write accesses have been detected on mr (while a chip select was active) or on csri (while the chip select ?i? was active) since the last read. 7 - the write protection has blocked a write access to a protected register. and - software reset has been performed while write protection was enabled. and - write accesses have been detected on mr (while a chip select was active) or on csri (while the chip select ?i? was active) since the last read.
700 42023e?sam?07/2013 atsam4l8/l4/l2 26.8.15 features register register name: features access type: read-only offset: 0xf8 reset value: ? ? swimpl: spurious write protection implemented 0: spurious write protec tion is not implemented. 1: spurious write prot ection is implemented. ? fiforimpl: fifo in reception implemented 0: fifo in receptio n is not implemented. 1: fifo in recept ion is implemented. ? brpbhsb: bridge type is pb to hsb 0: bridge type is not pb to hsb. 1: bridge type is pb to hsb. ? csnaatimpl: csnaat features implemented 0: csnaat (chip select not active after transfer) features are not implemented. 1: csnaat features are implemented. ? extdec: external decoder true 0: external decoder capability is not implemented. 1: external decoder capability is implemented. ? lennconf: character length if not configurable if the character length is not configurable, th is field specifies the fixed character length. ? lenconf: character length configurable 0: the character length is not configurable. 1: the character length is configurable. ? phznconf: phase is zero if phase not configurable 0: if phase is not config urable, phase is non-zero. 1: if phase is not configurable, phase is zero. ? phconf: phase configurable 0: phase is not configurable. 1: phase is configurable. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 - - - swimpl fiforimpl brpbhsb csnaatimpl extdec 15 14 13 12 11 10 9 8 lennconf lenconf 76543210 phznconf phconf ppnconf pconf ncs
701 42023e?sam?07/2013 atsam4l8/l4/l2 ? ppnconf: polarity positive if polarity not configurable 0: if polarity is not configurable, polarity is negative. 1: if polarity is not configurable, polarity is positive. ? pconf: polarity configurable 0: polarity is not configurable. 1: polarity is configurable. ? ncs: number of chip selects this field indicates the number of chip selects implemented.
702 42023e?sam?07/2013 atsam4l8/l4/l2 26.8.16 version register register name: version access type: read-only offset: 0xfc reset value: ? ? mfn reserved. no functionality associated. ? version version number of the module. no functionality associated. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 ---- mfn 15 14 13 12 11 10 9 8 version[11:8] 76543210 version[7:0]
703 42023e?sam?07/2013 atsam4l8/l4/l2 26.9 module configuration the specific configuration for each spi instance is listed in the following tables.the module bus clocks listed here are connected to the system bus clocks. refer to section 10. ?power manager (pm)? on page 108 for details. table 26-4. spi clock name module name clock name description spi clk_spi clock for the spi bus interface table 26-5. register reset values register reset value features 0x001f0154 version 0x00000211
704 42023e?sam?07/2013 atsam4l8/l4/l2 27. two-wire master interface (twim) rev: 1.2.0.1 27.1 features ? compatible with i 2 c standard ? multi-master support ? transfer speeds up to 3.4 mbit/s ? 7- and 10-bit and general call addressing ? compatible with smbus standard ? hardware packet error checking (crc) ge neration and verification with ack control ? 25 ms clock low timeout delay ? 10 ms master cumulative clock low extend time ? 25 ms slave cumulative clock low extend time ? compatible with pmbus ? compatible with atmel two-wi re interface serial memories ? dma interface for reducing cpu load ? arbitrary transfer lengths, including 0 data bytes ? optional clock stretching if transmit or receive buffers not ready for data transfer 27.2 overview the atmel two-wire master interface (twim) in terconnects components on a unique two-wire bus, made up of one clock line and one data line with speeds of up to 3.4 mbit/s, based on a byte-oriented transfer format. it can be used with any atmel two-wire interface bus serial eeprom and i2c compatible device such as a real time clock (rtc), dot matrix/graphic lcd controller, and temperature sensor, to name a few. the twim is always a bus master and can transfer sequential or single byte s. multiple master capability is supported. arbitration of the bus is performed internally and relin quishes the bus automatically if the bus arbitration is lost. a configurable baud rate generator permits the output data rate to be adapted to a wide range of core clock frequencies. table 27-1 lists the compatibilit y level of the atmel two-wire interface in master mode and a full i2c compatible device. note: 1. start + b000000001 + ack + sr table 27-1. atmel twim compatib ility with i2c standard i2c standard atmel twim standard-mode (100 kbit/s) supported fast-mode (400 kbit/s) supported fast-mode plus (1 mbit/s) supported high-speed-mode (3.4 mbit/s) supported 7- or 10-bits slave addressing supported start byte (1) not supported repeated start (sr) condition supported ack and nack management supported slope control and input filtering (fast mode) supported clock stretching supported
705 42023e?sam?07/2013 atsam4l8/l4/l2 table 27-2 lists the compatibility level of the atmel two-wire master interface and a full smbus compatible master. 27.3 list of abbreviations 27.4 block diagram figure 27-1. block diagram table 27-2. atmel twim compatibilit y with smbus standard smbus standard atmel twim bus timeouts supported address resolution protocol supported host functionality supported packet error checking supported table 27-3. abbreviations abbreviation description twi two-wire interface a acknowledge na non acknowledge pstop sstart sr repeated start sadr slave address adr any address except sadr r read wwrite peripheral bus bridge two-wire interface i/o controller twck twd interrupt controller twi interrupt power manager clk_twim
706 42023e?sam?07/2013 atsam4l8/l4/l2 27.5 application block diagram figure 27-2. application block diagram 27.6 i/o lines description 27.7 product dependencies in order to use this module, other parts of the system must be configured correctly, as described below. 27.7.1 i/o lines twd and twck are bidirectional lines, connected to a positive supply voltage via a current source or pull-up resistor (see figure 27-4 on page 708 ). when the bus is free, both lines are high. the output stages of devices connected to the bus must have an open-drain or open-col- lector to perform the wired-and function. the twd and twck pins may be multiplexed with i/o controller lines. to enable the twim, the user must perform the following steps: ? program the i/o controller to: ? dedicate twd, twck as peripheral lines. ? define twd, twck as open-drain. 27.7.2 power management if the cpu enters a sleep mode th at disables clocks used by t he twim, the twim will stop func- tioning and resume operation after the system wakes up from sleep mode. twi master twd twck atmel twi serial eeprom i 2 c rtc i 2 c lcd controller i 2 c temp sensor slave 2slave 3slave 4 vdd rp: pull-up value as given by the i2c standard slave 1 rp rp table 27-4. i/o lines description pin name pin description type twd two-wire serial data input/output twck two-wire serial clock input/output
707 42023e?sam?07/2013 atsam4l8/l4/l2 27.7.3 clocks the clock for the twim bus interface (clk_twim) is generated by the power manager. it is rec- ommended to disable the twim before disabling t he clock, to avoid freezing the twim in an undefined state. 27.7.4 dma the twim dma handshake interface is connected to the peripheral dma controller. using the twim dma functionality requires the peripheral dma controller to be programmed after setting up the twim. 27.7.5 interrupts the twim interrupt request lines are connected to the nvic. using the twim interrupts requires the nvic to be programmed first. 27.7.6 debug operation when an external debugger forces the cpu into debug mode, the twim continues normal oper- ation. if the twim is configured in a way that requires it to be periodically serviced by the cpu through interrupts or similar, improper operation or data loss may result during debugging.
708 42023e?sam?07/2013 atsam4l8/l4/l2 27.8 functional description 27.8.1 transfer format the data put on the twd line must be 8 bits long. data is transferred msb first; each byte must be followed by an acknowledgement. the number of bytes per transfer is unlimited (see figure 27-4 ). each transfer begins with a start condition and terminates with a stop condition (see figure 27-4 ). ? a high-to-low transition on the twd line while twck is high defines the start condition. ? a low-to-high transition on the twd line while twck is high defines a stop condition. figure 27-3. start and stop conditions figure 27-4. transfer format 27.8.2 operation the twim has two modes of operation: ? master transmitter mode ? master receiver mode the master is the device which starts and stops a transfer and generates the twck clock. these modes are described in the following chapters. twd twck start stop twd twck start address r/w ack data ack data ack stop
709 42023e?sam?07/2013 atsam4l8/l4/l2 27.8.2.1 high-speed-mode after reset and initialization, the twim is in standard-mode, fast-mode, or fast-mode plus (col- lectively referred to as the f/s-mode). for the twim to enter high-speed-mode (hs-mode), the user must write a one to the hs-mode (hs) bit and write a unique 3-bit code to the hs-mode master code field (hsmcode) in the command register (cmdr) or/and the next command register (ncmdr). this instructs the twim to in itiate a hs-mode transfer, when the bus is free, by transmitting (in f/s-mode) the start cond ition followed by a uni que 8-bit hs-mode master code (0x00001xxx), which is fo rmed by prefixing cmdr.hsmco de with 0b00001. this is then followed by the not-acknowledge bit (na) on the bus, after which hs-mode transfer commences. in summary, the conditions for initiating hs-mode transfer are: 1. start condition (s) 2. 8-bit master code (0000 1xxx) 3. not-acknowledge bit (na) hs-mode master codes are reserved 8-bit codes and serve two purposes: 1. it allows arbitration and synchronization between competing masters at f/s-mode speeds, resulting in one winning master. 2. it indicates the beginning of an hs-mode transfer. if the twim remains as the active master after the transmission of the master code and the na bit, it releases the twck line and waits for the line to be pulled up to high, during which it does the following: 1. adapt the twd and twck input filters to the spike suppression requirement in hs- mode. 2. adapt the twd and twck output stages to the slope control requirements in hs- mode. once the twck line is high, the twim operates in hs-mode and only switches back to f/s- mode after a stop condition. if an acknowledge bit (a) is erroneously placed on the bus after the transmission of the master code, the twim sets the hsmcack bit in the status register (sr) and transmits the stop condition on the bus. with regard to the slope control of the twd and twck outputs, the user can control the rise and fall times of the twck output in f/s- and hs-mode by writing the clock drive strength high/low (cldriveh/l) and clock slew limit (clslew) fields of the slew rate register (srr) and hs-mode slew rate register (hssrr), respectively. likewise, the fall times of the twd output in f/s- and hs-mode can be controlled by writing the data drive strength low (dadrivel) and data slew limit (daslew) fields of srr and hssrr, respectively. refer to section 42. ?electrical characteristics? on page 1120 for appropriates values of these register fields. note that the fall times of the twd output are also controlled by the corresponding register fields in the two-wire slave interface (twis) module. in order to correctly control the slew rate of the twd output, the user must either 1. write the relevant register fields in the twim with appropriate values and leave those in twis as zeros, or vice versa; or 2. write the relevant register fields in both the twim and the twis with the same values. during hs-mode transfer, the twim enables and controls a current-source pull-up circuit at the output stage of its twck signal (if it is the active master) to shorten the rise time of the signal. the current-source pull- up circuit is temporarily disabl ed by the twim after a repeated start condition and after each acknowledge bit (a) and not-acknowledge bit (na), thus enabling other devices connected to the bus to del ay the serial transfer by stretching the low
710 42023e?sam?07/2013 atsam4l8/l4/l2 period of the twck signal. the twim enables its current-source pull-up circuit again when all devices have released the twck line and the line reaches a high level. 27.8.2.2 clock generation when the twim is in f/s-mode, theclock waveform generator register (cwgr) is used to control the waveform of the twck clock. cwgr must be written so that the desired twi bus timings are generated. cwgr describes bus timings as a function of cycles of a prescaled clock. the clock prescaling can be selected through the clock prescaler field in cwgr (cwgr.exp). cwgr has the following fields: low: prescaled clock cycles in cl ock low count. used to time t low and t buf . high: prescaled clock cycles in cl ock high count. used to time t high . stasto: prescaled clock cycles in cl ock high count. used to time t hd_sta , t su_sta , t su_sto . data: prescaled clock cycles for data setu p and hold count. used to time t hd_dat , t su_dat . exp: specifies the clo ck prescaler setting. note that the total clock low time generated is the sum of t hd_dat + t su_dat + t low . any slave or other bus master taking part in the transfer may extend the twck low period at any time. the twim hardware monitors the state of the tw ck line as required by the i2c specification. the clock generation counters are started when a high/low level is detected on the twck line, not when the twim hardware releases/drives the twck line. this means that the cwgr set- tings alone do not determine the twck frequency. the cwgr settings determine the clock low time and the clock high time, but the twck rise a nd fall times are determined by the external cir- cuitry (capacitive load, etc.). when the twim is in hs-mode , the hs-mode clock waveform generator register (hscwgr), instead of cwgr, is used to generate the twck signal. hscwgr has the same fields as cwgr serving the same purposes. f prescaler f clk_twim 2 exp 1 + () ------------------------- - =
711 42023e?sam?07/2013 atsam4l8/l4/l2 figure 27-5. bus timing diagram 27.8.2.3 setting up and performing a transfer operation of the twim is mainly controlled by the control register (cr) and the command reg- ister (cmdr). twim status is pr ovided in the status register (sr). the following list presents the main steps in a typical communication: 1. before any transfers can be performed, bus timings must be configured by writing to the clock waveform generator register (cwgr) and, if hs-mode is supported, the hs- mode clock waveform generator register (hscwgr). if operating in smbus mode, the smbus timing register (smbtr) register must also be configured. 2. if the peripheral dma controller is to be used for the transfers, it must be set up. 3. cmdr or ncmdr must be written with a value describing the transfer to be performed. the interrupt system can be set up to give interrupt requests on specific events or error condi- tions in the sr, for example when the transfer is complete or if arbitration is lost. the interrupt enable register (ier) and interrupt disable register (idr) can be written to specify which bits in the sr will generate interrupt requests. the sr.busfree bit is set when activity is co mpleted on the two-wire bus. the sr.crdy bit is set when cmdr and/or ncmdr is read y to receive one or more commands. the controller will refuse to start a new trans fer while anak, dnak,, arblst, or hsmcack in the status register (sr) is one. this is necess ary to avoid a race when the software issues a continuation of the current transfer at the same time as one of these errors happen. also, if anak or dnak occurs, a stop co ndition is sent auto matically. the user will have to restart the transmission by clearing the error bits in sr after resolving the cause for the nack. after a data or address nack from the slave, a stop will be transmitted automatically. note that the valid bit in cmdr is not cleared in this case. if this transfer is to be discarded, the valid bit can be cleared manually allowing any command in ncmdr to be copied into cmdr. when a data or address nack is returned by the slave while the master is transmitting, it is pos- sible that new data has already been written to th e thr register. this data will be tran sferred out as the first data byte of the next transfer. if this behavior is to be avoided, the safest approach is to perform a software reset of the twim. s t hd:sta t low t su:dat t high t hd:dat t low p t su:sto sr t su:sta t su:dat
712 42023e?sam?07/2013 atsam4l8/l4/l2 27.8.3 master transmitter mode a start condition is transmitted and master trans mitter mode is initiated when the bus is free and cmdr has been written with start=1 and read=0. start and sadr+w will then be transmitted. during the address acknowledge clock pulse (9th pulse), the master releases the data line (high), enabling the slave to pull it down in order to acknowledge the address. the master polls the data line during this clock pulse and sets the address not acknowledged bit (anak ) in the status register if no slave acknowledges the address. after the address phase, the following is repeated: while (nbytes>0) 1. wait until thr contains a valid data byte, stretching low period of twck. sr.txrdy indicates the state of thr. software or the peripheral dma controller must write the data byte to thr. 2. transmit this data byte 3. decrement nbytes 4. if (nbytes==0) and stop=1, transmit stop condition writing cmdr with start=stop=1 and nbytes= 0 will generate a transm ission with no data bytes, ie start, sadr+w, stop. twi transfers require the slave to acknowle dge each received data byte. during the acknowl- edge clock pulse (9th pulse), the master releases the data line (high), enabling the slave to pull it down in order to generate the acknowledge. t he master polls the data line during this clock pulse and sets the data acknowledge bit (dnack) in the status register if the slave does not acknowledge the data byte. as with the other status bits, an interrupt can be generated if enabled in the interrupt enable register (ier). txrdy is used as transmit ready for the pe ripheral dma controller transmit channel. the end of a command is marked when the twim sets the sr.ccomp bit. see figure 27-6 and figure 27-7 . figure 27-6. master write with one data byte twd sr.idle txrdy write thr (data) nbytes set to 1 stop sent automatically (ack received and nbytes=0) sdadr wa data ap
713 42023e?sam?07/2013 atsam4l8/l4/l2 figure 27-7. master write with mu ltiple data bytes 27.8.4 master receiver mode a start condition is transmitted and master receiver mode is initiated when the bus is free and cmdr has been written with start=1 and read=1. start and sadr+r will then be trans- mitted. during the address acknowledge clock puls e (9th pulse), the master releases the data line (high), enabling the slave to pull it down in order to acknowledge the address. the master polls the data line during this clock pulse and sets the address not acknowledged bit (anak) in the status register if no slave acknowledges the address. after the address phase, the following is repeated: while (nbytes>0) 1. wait until rhr is empty, stretching low period of twck. sr.rxrdy indicates the state of rhr. software or the peripheral dma controller must read any data byte present in rhr. 2. release twck generating a clock that the slave uses to transmit a data byte. 3. place the received data byte in rhr, set rxrdy. 4. if nbytes=0, generate a nak after the data byte, otherwise generate an ack. 5. decrement nbytes 6. if (nbytes==0) and stop=1, transmit stop condition. writing cmdr with start=stop=1 and nbytes= 0 will generate a transm ission with no data bytes, ie start, dadr+r, stop the twi transfers require the master to a cknowledge each received data byte. during the acknowledge clock pulse (9th pulse), the slave releases the data line (high), enabling the mas- ter to pull it down in order to generate the acknowledge. all data bytes except the last are acknowledged by the master. not acknowledging the last byte informs the slave that the transfer is finished. rxrdy is used as receive ready for the peripheral dma controller receive channel. twd sr.idle txrdy write thr (datan) nbytes set to n stop sent automatically (ack received and nbytes=0) sdadr wa datan a datan+5 aa datan+m p write thr (datan+1) write thr (datan+m) last data sent
714 42023e?sam?07/2013 atsam4l8/l4/l2 figure 27-8. master read with one data byte figure 27-9. master read with mu ltiple data bytes 27.8.5 using the peripheral dma controller the use of the peripheral dma controller signifi cantly reduces the cpu load. the user can set up ring buffers for the peripheral dma controller, containing data to transmit or free buffer space to place received data. to assure correct behavior, respect the following programming sequences: 27.8.5.1 data transmit with the peripheral dma controller 1. initialize the transmit peripheral dma controller (memory pointers, size, etc.). 2. configure the twim (adr, nbytes, etc.). 3. start the transfer by enabling the peripheral dma controller to transmit. 4. wait for the peripheral dma controller end-of-transmit flag. 5. disable the peripheral dma controller. 27.8.5.2 data receive with th e peripheral dma controller 1. initialize the receive peripheral dma controller (memory pointers, size, etc.). 2. configure the twim (adr, nbytes, etc.). 3. start the transfer by enabling the peripheral dma controller to receive. 4. wait for the peripheral dma controller end-of-receive flag. 5. disable the peripheral dma controller. twd sr.idle rxrdy write start & stop bit nbytes set to 1 read rhr sdadr r a data np twd sr.idle rxrdy write start + stop bit nbytes set to m sdadr r a datan a datan+m-1 an datan+m p read rhr datan datan+1 read rhr datan+m-2 read rhr datan+m-1 read rhr datan+m send stop when nbytes=0
715 42023e?sam?07/2013 atsam4l8/l4/l2 27.8.6 multi-master mode more than one master may access the bus at the same time without data corruption by using arbitration. arbitration starts as soon as two or more masters place information on the bus at the same time, and stops (arbitration is lost) for the master that intends to send a logical one while the other master sends a logical zero. as soon as arbitration is lost by a master, it st ops sending data and listens to the bus in order to detect a stop. the sr.arblst flag will be set. when the stop is detected, the master who lost arbitration may reinitiate the data transfer. arbitration is illustrated in figure 27-11 . if the user starts a transfer and if the bus is busy, the twim automatically waits for a stop con- dition on the bus before initiating the transfer (see figure 27-10 ). note: the state of the bus (busy or free) is not indicated in the user interface. figure 27-10. user sends data while the bus is busy twck twd data sent by a master stop sent by the master start sent by the twi data sent by the twi bus is busy bus is free a transfer is programmed (dadr + w + start + write thr) transfer is initiated twi data transfer transfer is kept bus is considered as free
716 42023e?sam?07/2013 atsam4l8/l4/l2 figure 27-11. arbitration cases 27.8.7 combined transfers cmdr and ncmdr may be used to generate longer sequences of connected transfers, since generation of start and/or stop conditions is programmable on a per-command basis. writing ncmdr with start=1 when the previous transfer was written with stop=0 will cause a repeated start on the bus. the ability to gener ate such connected tr ansfers allows arbi- trary transfer lengths, since it is legal to write cmdr with both start=0 and stop=0. if this is done in master receiver mode, the cmdr.acklast bit must also be controlled. as for single data transfers, the txrdy and rxrd y bits in the status register indicates when data to transmit can be written to thr, or when received data can be read from rhr. transfer of data to thr and from rhr can also be done automatically by dma, see section 27.8.5 27.8.7.1 write followed by write consider the fo llowing transfer: start, dadr+w, data+a, data+a, repstart, dadr+w, data+a, data+a, stop. to generate this transfer: 1. write cmdr with start=1, stop=0, dadr, nbytes=2 and read=0. 2. write ncmdr with start=1, stop=1, dadr, nbytes=2 and read=0. 3. wait until sr.txrdy==1, then write first data byte to transfer to thr. 4. wait until sr.txrdy==1, then write second data byte to transfer to thr. 5. wait until sr.txrdy==1, then write third data byte to transfer to thr. twck bus is busy bus is free a transfer is programmed (dadr + w + start + write thr) transfer is initiated twi data transfer transfer is kept bus is considered as free data from a master data from twi s 0 s 0 0 1 1 1 arblst s 0 s 0 0 1 1 1 twd s 0 0 1 1 1 1 1 arbitration is lost twi stops sending data p s 0 1 p 0 1 1 1 1 data from the master data from the twi arbitration is lost the master stops sending data transfer is stopped transfer is programmed again (dadr + w + start + write thr) twck twd
717 42023e?sam?07/2013 atsam4l8/l4/l2 6. wait until sr.txrdy==1, then write fourth data byte to transfer to thr. 27.8.7.2 read followed by read consider the fo llowing transfer: start, dadr+r, data+a, data+na, repstart, dadr+r, data+a, data+na, stop. to generate this transfer: 1. write cmdr with start=1, stop=0, dadr, nbytes=2 and read=1. 2. write ncmdr with start=1, stop=1, dadr, nbytes=2 and read=1. 3. wait until sr.rxrdy==1, then read first data byte received from rhr. 4. wait until sr.rxrdy==1, then read second data byte received from rhr. 5. wait until sr.rxrdy==1, then read third data byte received from rhr. 6. wait until sr.rxrdy==1, then read fourth data byte received from rhr. if combining several tr ansfers, without any stop or repeated start between them, remem- ber to write a one to the acklast bit in cmdr to keep from ending each of the partial transfers with a nack. 27.8.7.3 write followed by read consider the fo llowing transfer: start, dadr+w, data+a, data+a, repstart, dadr+r, data+a, data+na, stop. figure 27-12. combining a write and read transfer to generate this transfer: 1. write cmdr with start=1, stop=0, dadr, nbytes=2 and read=0. 2. write ncmdr with start=1, stop=1, dadr, nbytes=2 and read=1. 3. wait until sr.txrdy==1, then write first data byte to transfer to thr. 4. wait until sr.txrdy==1, then write second data byte to transfer to thr. 5. wait until sr.rxrdy==1, then read first data byte received from rhr. 6. wait until sr.rxrdy==1, then read second data byte received from rhr. 27.8.7.4 read followed by write consider the fo llowing transfer: start, dadr+r, data+a, data+na, repstart, dadr+w, data+a, data+a, stop. twd sr.idle txrdy sdadr wa data0 a data1 na sr dadr r a data2 a data3 a p data0 data1 thr rxrdy 1 rhr data3 data2
718 42023e?sam?07/2013 atsam4l8/l4/l2 figure 27-13. combining a read and write transfer to generate this transfer: 1. write cmdr with start=1, stop=0, dadr, nbytes=2 and read=1. 2. write ncmdr with start=1, stop=1, dadr, nbytes=2 and read=0. 3. wait until sr.rxrdy==1, then read first data byte received from rhr. 4. wait until sr.rxrdy==1, then read second data byte received from rhr. 5. wait until sr.txrdy==1, then write first data byte to transfer to thr. 6. wait until sr.txrdy==1, then write second data byte to transfer to thr. 27.8.8 ten bit addressing writing a one to cmdr.tenbit enables 10-bit addressing in hardware. performing transfers with 10-bit addressing is similar to transfers with 7-bit addresses, except that bits 9:7 of cmdr.sadr must be written appropriately. in figure 27-14 and figure 27-15 , the grey boxes represent signals driven by the master, the white boxes are driven by the slave. 27.8.8.1 master transmitter to perform a master transmitter transfer: 1. write cmdr with tenbit=1, repsame=0, read=0, start=1, stop=1 and the desired address and nbytes value. figure 27-14. a write transfer with 10-bit addressing 27.8.8.2 master receiver when using master receiver mode with 10-bit addressing, cm dr.repsame must also be con- trolled. cmdr.repsame must be written to one when the address phase of the transfer should consist of only 1 address byte (the 11110xx byte) and not 2 address bytes. the i2c standard specifies that such addressing is required wh en addressing a slave for reads using 10-bit addressing. to perform a master receiver transfer: twd sr.idle txrdy s sadr r a data0 a data1 sr dadr w a data2 a data3 na p data2 thr rxrdy rhr data3 data0 a 1 2 data3 read twi_rhr s slave address 1st 7 bits p a data rw a1 a2 slave address 2nd byte aa data 11110xx0
719 42023e?sam?07/2013 atsam4l8/l4/l2 1. write cmdr with tenbit=1, repsam e=0, read=0, start=1, stop=0, nbytes=0 and the desired address. 2. write ncmdr with tenbit=1, repsame=1, read=1, start=1, stop=1 and the desired address and nbytes value. figure 27-15. a read transfer with 10-bit addressing 27.8.9 smbus mode smbus mode is enabled and disabled by writing to the smen and smdis bits in cr. smbus mode operation is similar to i2c ope ration with the following exceptions: ? only 7-bit addressing can be used. ? the smbus standard describes a set of timeout values to ensure progress and throughput on the bus. these timeout values must be written into smbtr. ? transmissions can optionally include a crc byte, called packet error check (pec). ? a set of addresses have been reserved for protocol handling, such as alert response address (ara) and host header (hh) address. 27.8.9.1 packet error checking each smbus transfer can optionally end with a crc byte, called the pec byte. writing a one to cmdr.pecen enables automatic pec handling in the current transfer. transfers with and with- out pec can freely be intermixed in the same system, since some slaves may not support pec. the pec lfsr is always updated on every bit transmitted or received, so that pec handling on combined transfers will be correct. in master transmitter mode, the master calculates a pec value and transmits it to the slave after all data bytes have been transm itted. upon reception of this pec byte, the slave will compare it to the pec value it has computed itself. if the values match, the data was received correctly, and the slave will return an ack to th e master. if the pec values differ, data was corrupted, and the slave will return a nack value. the dnak bit in sr reflects the state of the last received ack/nack value. some slaves may not be able to check the received pec in time to return a nack if an error occurred. in this case, the slave should always retu rn an ack after the pec byte, and some other mechanism must be implemented to verify that the transmission was received correctly. in master receiver mode, the slave calculates a pec value and transmits it to the master after all data bytes have been transmitted. upon reception of this pec by te, the master will compare it to the pec value it has computed itself. if the values match, the data was received correctly. if the pec values differ, data was corrupted, and sr.pecerr is set. in master receiver mode, the pec byte is always followed by a nack transmitted by the master, since it is the last byte in the transfer. the pec byte is automatically inserted in a master transmitter transmission if pec is enabled when nbytes reaches zero. the pec byte is identified in a master receiver transmission if pec is enabled when nbytes reaches zero. nbytes must therefore be written with the total number of data bytes in the transmission, including the pec byte. s slave address 1st 7 bits p a data rw a1 a2 slave address 2nd byte a data 11110xx0 sr slave address 1st 7 bits rw a3 11110xx1
720 42023e?sam?07/2013 atsam4l8/l4/l2 in combined transfers, the pecen bit should only be written to one in the last of the combined transfers. consider the following transfer: s, adr+w, command_byte, ack, sr, adr+ r, data_byte, ack, pec_byte, nack, p this transfer is generated by writing two commands to the command registers. the first com- mand is a write with nbytes=1 and pecen=0, and the second is a read with nbytes=2 and pecen=1. writing a one to the stop bit in cr will pl ace a stop condition on the bus after the current byte. no pec byte will be sent in this case. 27.8.9.2 timeouts the tlows and tlowm fields in smbtr confi gure the smbus timeout values. if a timeout occurs, the master will transmit a stop conditi on and leave t he bus. the sr.tout bit is set. 27.8.10 identifying bus events this chapter lists the different bus events, and how they affect bits in the twim registers. this is intended to help writin g drivers for the twim. table 27-5. bus events event effect master transmitter has sent a data byte sr.thr is cleared. master receiver has received a data byte sr.rhr is set. start+sadr sent, no ack received from slave sr.anak is set. sr.ccomp not set. cmdr.valid remains set. stop automatically transmitted on bus. data byte sent to slave, no ack received from slave sr.dnak is set. sr.ccomp not set. cmdr.valid remains set. stop automatically transmitted on bus. arbitration lost sr.arblst is set. sr.ccomp not set. cmdr.valid remains set. twck and twd immediately released to a pulled-up state. smbus timeout received sr.smbtout is set. sr.ccomp not set. cmdr.valid remains set. stop automatically transmitted on bus.
721 42023e?sam?07/2013 atsam4l8/l4/l2 master transmitter receives smbus pec error sr.dnak is set. sr.ccomp not set. cmdr.valid remains set. stop automatically transmitted on bus. master receiver discovers smbus pec error sr.pecerr is set. sr.ccomp not set. cmdr.valid remains set. stop automatically transmitted on bus. cr.stop is written by user sr.stop is set. sr.ccomp set. cmdr.valid remains set. stop transmitted on bus after curr ent byte transfer has finished. table 27-5. bus events event effect
722 42023e?sam?07/2013 atsam4l8/l4/l2 27.9 user interface note: 1. the reset values for these registers are device specific. refer to the module configuration section at the end of this c hapter. table 27-6. twim register memory map offset register register name access reset 0x00 control register cr write-only 0x00000000 0x04 clock waveform generator register cwgr read/write 0x00000000 0x08 smbus timing register smbtr read/write 0x00000000 0x0c command register cmdr read/write 0x00000000 0x10 next command register ncmdr read/write 0x00000000 0x14 receive holding register rhr read-only 0x00000000 0x18 transmit holding register thr write-only 0x00000000 0x1c status register sr read-only 0x00000002 0x20 interrupt enable register ier write-only 0x00000000 0x24 interrupt disable register idr write-only 0x00000000 0x28 interrupt mask register imr read-only 0x00000000 0x2c status clear register scr write-only 0x00000000 0x30 parameter register pr read-only - (1) 0x34 version register vr read-only - (1) 0x38 hs-mode clock waveform generator hscwgr read/write 0x00000000 0x3c slew rate register srr read/write 0x00000000 0x40 hs-mode slew rate register hssrr read/write 0x00000000
723 42023e?sam?07/2013 atsam4l8/l4/l2 27.9.1 control register name: cr access type: write-only offset: 0x00 reset value: 0x00000000 ? stop: stop the current transfer writing a one to this bit terminates the current transfer, sendi ng a stop condition after the shifter has become idle. if there are additional pending transfers, they will have to be explicitly re started by software after the stop condition has been successfu lly sent. writing a zero to this bit has no effect. ? swrst: software reset if the twim master interface is enabled, writing a one to this bit resets the twim. all transfers are halted immediately, possi bly violating the bus semantics. if the twim master interface is not enabled, it must first be enabled before writing a one to this bit. writing a zero to this bit has no effect. ? smdis: smbus disable writing a one to this bit disables smbus mode. writing a zero to this bit has no effect. ? smen: smbus enable writing a one to this bit enables smbus mode. writing a zero to this bit has no effect. ? mdis: master disable writing a one to this bit disables the master interface. writing a zero to this bit has no effect. ? men: master enable writing a one to this bit enables the master interface. writing a zero to this bit has no effect. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------stop 76543210 swrst - smdis smen - - mdis men
724 42023e?sam?07/2013 atsam4l8/l4/l2 27.9.2 clock waveform generator register name: cwgr access type: read/write offset: 0x04 reset value: 0x00000000 ? exp: clock prescaler used to specify how to prescale the twck clock. coun ters are prescaled according to the following formula ? data: data setu p and hold cycles clock cycles for data setup and hold count. prescaled by cwgr.exp . used to time t hd_dat , t su_dat . ? stasto: start and stop cycles clock cycles in clock high count. prescaled by cwgr.exp. used to time t hd_sta , t su_sta , t su_sto ? high: clock high cycles clock cycles in clock high count. prescaled by cwgr.exp. used to time t high . ? low: clock low cycles clock cycles in clock low count. pre scaled by cwgr.exp. used to time t low , t buf . 31 30 29 28 27 26 25 24 - exp data 23 22 21 20 19 18 17 16 stasto 15 14 13 12 11 10 9 8 high 76543210 low f prescaler f clk_twim 2 exp 1 + () ------------------------- - =
725 42023e?sam?07/2013 atsam4l8/l4/l2 27.9.3 smbus timing register name: smbtr access type: read/write offset: 0x08 reset value: 0x00000000 ? exp: smbus timeout clock prescaler used to specify how to prescale the ti m and tlowm counters in smbtr. counters are prescaled according to the following formula ? thmax: clock high maximum cycles clock cycles in clock high maximum count. prescaled by smbtr.exp. used for bus free de tection. used to time t high:max . note: uses the prescaler specified by cw gr, not the prescaler specified by smbtr. ? tlowm: master clock stretch maximum cycles clock cycles in master maximum clock stretch count. prescaled by smbtr.exp. used to time t low:mext ? tlows: slave clock stretch maximum cycles clock cycles in slave maximum clock stretch coun t. prescaled by smbtr.exp. used to time t low:sext . 31 30 29 28 27 26 25 24 exp ---- 23 22 21 20 19 18 17 16 thmax 15 14 13 12 11 10 9 8 tlowm 76543210 tlows f prescaled smbus , f clktwim 2 exp 1 + () ------------------------ =
726 42023e?sam?07/2013 atsam4l8/l4/l2 27.9.4 command register name: cmdr access type: read/write offset: 0x0c reset value: 0x00000000 ? hsmcode: hs-mode master code 3-bit code to be prefixed with 0b00001 to form a unique 8-bit hs-mode master code (0000 1xxx). ?hs: hs-mode 0: causes the twim not to initiate hs-mode transfer. 1: causes the twim to initiate hs-mode transfer. ? acklast: ack last master rx byte 0: causes the last byte in master re ceive mode (when nbytes has reached 0) to be nacked. this is the standard way of ending a master receiver transfer. 1: causes the last byte in master re ceive mode (when nbytes has reached 0) to be acked. used for performing linked transfers in master receiver mode with no stop or repeated start between the subtransfers. this is needed when more than 255 bytes are to be received in one single transmission. ? pecen: packet error checking enable 0: causes the transfer not to use pec byte verification. the pec lfsr is still updated for every bit transmitted or received. m ust be used if smbus mode is disabled. 1: causes the transfer to use pec. pec byte generation (if master transmitter) or pec byte verifi cation (if master receiver) wi ll be performed. ? nbytes: number of data bytes in transfer the number of data bytes in the transfer. after the specified number of bytes have been transferred, a stop condition is transmitted if cmdr.stop is one. in smbus mode, if pec is used, nbytes includes the pec byte, i.e. there are nbytes-1 data bytes and a pec byte. ? valid: cmdr valid 0: indicates that cmdr does not contain a valid command. 1: indicates that cmdr contains a valid command. this bit is cleared when the command is finished. ? stop: send stop condition 0: do not transmit a stop condition af ter the data bytes have been transmitted. 1: transmit a stop condition after t he data bytes have been transmitted. ? start: send start condition 0: the transfer in cmdr should not commen ce with a start or repeated start condition. 31 30 29 28 27 26 25 24 - hsmcode - hs acklast pecen 23 22 21 20 19 18 17 16 nbytes 15 14 13 12 11 10 9 8 valid stop start repsame tenbit sadr[9:7] 76543210 sadr[6:0] read
727 42023e?sam?07/2013 atsam4l8/l4/l2 1: the transfer in cmdr should commence with a start or re peated start condition. if the bus is free when the command is executed, a start condition is used. if the bus is busy, a repeated start is used. ? repsame: transfer is to same address as previous address only used in 10-bit addressing mode, always write to 0 in 7-bit addressing mode. write this bit to one if the command in cmdr performs a repeated start to the same slave address as addressed in the previous transfer in order to enter master receiver mode. write this bit to zero otherwise. ? tenbit: ten bit addressing mode 0: use 7-bit addressing mode. 1: use 10-bit addressing mode. must not be used when the twim is in smbus mode. ? sadr: slave address address of the slave involved in the transfer. bi ts 9-7 are don?t care if 7-bit addressing is used. ? read: transfer direction 0: allow the master to transmit data. 1: allow the master to receive data.
728 42023e?sam?07/2013 atsam4l8/l4/l2 27.9.5 next command register name: ncmdr access type: read/write offset: 0x10 reset value: 0x00000000 this register is identical to cmdr. when the valid bit in cmdr becomes 0, the content of ncmdr is copied into cmdr, clearing the valid bit in ncmdr. if the valid bit in cmdr is cleared when ncmdr is written, the content is copied immediately. 31 30 29 28 27 26 25 24 - hsmcode - hs acklast pecen 23 22 21 20 19 18 17 16 nbytes 15 14 13 12 11 10 9 8 valid stop start repsame tenbit sadr[9:7] 76543210 sadr[6:0] read
729 42023e?sam?07/2013 atsam4l8/l4/l2 27.9.6 receive holding register name: rhr access type: read-only offset: 0x14 reset value: 0x00000000 ? rxdata: received data when the rxrdy bit in the status regist er (sr) is one, this field contains a byte received from the twi bus. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------- 76543210 rxdata
730 42023e?sam?07/2013 atsam4l8/l4/l2 27.9.7 transmit holding register name: thr access type: write-only offset: 0x18 reset value: 0x00000000 ? txdata: data to transmit write data to be transf erred on the twi bus here. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------- 76543210 txdata
731 42023e?sam?07/2013 atsam4l8/l4/l2 27.9.8 status register name: sr access type: read-only offset: 0x1c reset value: 0x00000002 ? hsmcack: ack in hs-mode master code phase received this bit is one when an ack is erroneously received during a hs-mode master code phase. this bit is cleared by writing 1 to the corresp onding bit in the status clear register (scr). ? menb: master interface enable 0: master interface is disabled. 1: master interface is enabled. ? stop: stop request accepted this bit is one when a stop request caused by writing a one to cr.stop has been accepted, and transfer has stopped. this bit is cleared by writing 1 to the corresp onding bit in the status clear register (scr). ? pecerr: pec error this bit is one when a smbus pec error occurred. this bit is cleared by writing 1 to the corresp onding bit in the status clear register (scr). ?tout: timeout this bit is one when a smbus timeout occurred. this bit is cleared by writing 1 to the corresp onding bit in the status clear register (scr). ? arblst: arbitration lost this bit is one when the actual state of the sda line did not correspond to the data driven onto it, indicating a higher-priori ty transmission in progress by a different master. this bit is cleared by writing 1 to the corresp onding bit in the status clear register (scr). ? dnak: nak in data phase received this bit is one when no ack was received form slave during data transmission. this bit is cleared by writing 1 to the corresp onding bit in the status clear register (scr). ? anak: nak in address phase received this bit is one when no ack was received from slave during address phase this bit is cleared by writing 1 to the correspo nding bit in the status clear register (scr). ? busfree: two-wire bus is free this bit is one when activity has completed on the two-wire bus. otherwise, this bit is cleared. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 ------hsmcackmenb 15 14 13 12 11 10 9 8 - stop pecerr tout - arblst dnak anak 76543210 - - busfree idle ccomp crdy txrdy rxrdy
732 42023e?sam?07/2013 atsam4l8/l4/l2 ? idle: master interface is idle this bit is one when no command is in progress, and no command waiting to be issued. otherwise, this bit is cleared. ? ccomp: command complete this bit is one when the current command has completed successfully. this bit is zero if the command failed due to conditions such as a nak receved from slave. this bit is cleared by writing 1 to the corresp onding bit in the status clear register (scr). ? crdy: ready for more commands this bit is one when cmdr and/or ncmdr is ready to receive one or more commands. this bit is cleared when this is no longer true. ? txrdy: thr data ready this bit is one when thr is ready for one or more data bytes. this bit is cleared when this is no longer tr ue (i.e. thr is full or transmission has stopped). ? rxrdy: rhr data ready this bit is one when rx data are ready to be read from rhr. this bit is cleared when this is no longer true.
733 42023e?sam?07/2013 atsam4l8/l4/l2 27.9.9 interrupt enable register name: ier access type: write-only offset: 0x20 reset value: 0x00000000 writing a zero to a bit in this register has no effect. writing a one to a bit in this register will set the corresponding bit in imr 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 ------hsmcack- 15 14 13 12 11 10 9 8 - stop pecerr tout - arblst dnak anak 76543210 - - busfree idle ccomp crdy txrdy rxrdy
734 42023e?sam?07/2013 atsam4l8/l4/l2 27.9.10 interrupt disable register name: idr access type: write-only offset: 0x24 reset value: 0x00000000 writing a zero to a bit in this register has no effect. writing a one to a bit in this register will clear the corresponding bit in imr 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 ------hsmcack- 15 14 13 12 11 10 9 8 - stop pecerr tout - arblst dnak anak 76543210 - - busfree idle ccomp crdy txrdy rxrdy
735 42023e?sam?07/2013 atsam4l8/l4/l2 27.9.11 interrupt mask register name: imr access type: read-only offset: 0x28 reset value: 0x00000000 0: the corresponding interrupt is disabled. 1: the corresponding interrupt is enabled. this bit is cleared when the corresponding bit in idr is written to one. this bit is set when the corresponding bit in ier is written to one. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 ------hsmcack- 15 14 13 12 11 10 9 8 - stop pecerr tout - arblst dnak anak 76543210 - - busfree idle ccomp crdy txrdy rxrdy
736 42023e?sam?07/2013 atsam4l8/l4/l2 27.9.12 status clear register name: scr access type : write-only offset: 0x2c reset value: 0x00000000 writing a zero to a bit in this register has no effect. writing a one to a bit in this register will clear the corresponding bit in sr and the corresponding interrupt request. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 ------hsmcack- 15 14 13 12 11 10 9 8 - stop pecerr tout - arblst dnak anak 76543210 ----ccomp---
737 42023e?sam?07/2013 atsam4l8/l4/l2 27.9.13 parameter register name: pr access type: read-only offset: 0x30 reset value: - ?hs: hs-mode 0: high-speed-mode is not supported. 1: high-speed-mode is supported. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------- 76543210 -------hs
738 42023e?sam?07/2013 atsam4l8/l4/l2 27.9.14 version register name: vr access type: read-only offset: 0x34 reset value: - ? variant: variant number reserved. no functionality associated. ? version: version number version number of the module. no functionality associated. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 ---- variant 15 14 13 12 11 10 9 8 ---- version [11:8] 76543210 version [7:0]
739 42023e?sam?07/2013 atsam4l8/l4/l2 27.9.15 hs-mode clock waveform generator register name: hscwgr access type: read/write offset: 0x38 reset value: 0x00000000 this register is identical to cwgr. it is used to generate the twck signal during hs-mode transfer. 31 30 29 28 27 26 25 24 - exp data 23 22 21 20 19 18 17 16 stasto 15 14 13 12 11 10 9 8 high 76543210 low
740 42023e?sam?07/2013 atsam4l8/l4/l2 27.9.16 slew rate register name: srr access type: read/write offset :0x3c reset value: 0x00000000 ? filter: input spike filter control ? clslew: clock slew limit selects the slew limit of the twck output buffer in f/s-mode. ? cldrivel: clock drive strength low selects the pull-down drive strength of the twck output buffer in f/s-mode. ? daslew: data slew limit selects the slew limit of the twd output buffer in f/s-mode. ? dadrivel: data drive strength low selects the pull-down drive strength of the twd output buffer in f/s-mode. refer to section 42. ?electrical characteristics? on page 1120 for appropriates values of these register fields. 31 30 29 28 27 26 25 24 - - filter - - clslew 23 22 21 20 19 18 17 16 ----- cldrivel 15 14 13 12 11 10 9 8 ------ daslew 76543210 ----- dadrivel filter value function 0reserved 1reserved 2 standard- or fast-mode 3 fast-mode plus
741 42023e?sam?07/2013 atsam4l8/l4/l2 27.9.17 hs-mode slew rate register name: hssrr access type: read/write offset :0x40 reset value: 0x00000000 ? filter: input spike filter control 0: reserved 1: hs-mode 2: reserved 3: reserved ? clslew: clock slew limit selects the slew limit of the twck output buffer in hs-mode. ? cldriveh: clock drive strength high selects the pull-up drive strength of the twck output buffer in hs-mode. ? cldrivel: clock drive strength low selects the pull-down drive strength of the twck output buffer in hs-mode. ? daslew: data slew limit selects the slew limit of the twd output buffer in hs-mode. ? dadrivel: data drive strength low selects the pull-down drive strength of the twd output buffer in hs-mode. refer to section 42. ?electrical characteristics? on page 1120 for appropriates values of these register fields. 31 30 29 28 27 26 25 24 - - filter - - clslew 23 22 21 20 19 18 17 16 - - cldriveh - cldrivel 15 14 13 12 11 10 9 8 ------ daslew 76543210 - dadrivel
742 42023e?sam?07/2013 atsam4l8/l4/l2 27.10 module configuration the specific configuration for each twim inst ance is listed in the following tables.the module bus clocks listed here are connected to the system bus clocks. refer to section 10. ?power man- ager (pm)? on page 108 for details. note : twi2 and twi3 are master only. twi0 and twi1 are master and slave table 27-7. module clock name module name clock name description twim0 clk_twim0 clock for the twim0 bus interface twim1 clk_twim1 clock for the twim1 bus interface twim2 clk_twim2 clock for the twim2 bus interface twim3 clk_twim3 clock for the twim3 bus interface table 27-8. register reset values register reset value version 0x00000120 parameter 0x00000001
743 42023e?sam?07/2013 atsam4l8/l4/l2 28. two-wire slave interface (twis) rev: 1.4.0.1 28.1 features ? compatible with i 2 c standard ? transfer speeds up to 3.4 mbit/s ? 7 and 10-bit and general call addressing ? compatible with smbus standard ? hardware packet error checking (crc) ge neration and verification with ack response ? 25 ms clock low timeout delay ? 25 ms slave cumulative clock low extend time ? compatible with pmbus ? dma interface for reducing cpu load ? arbitrary transfer lengths, including 0 data bytes ? optional clock stretching if transmit or receive buffers not ready for data transfer ? 32-bit peripheral bus interface fo r configuration of the interface 28.2 overview the atmel two-wire slave interface (twis) interconnects components on a unique two-wire bus, made up of one clock line and one data line with speeds of up to 3.4 mbit/s, based on a byte-oriented transfer format. it can be used with any atmel two-wire interface bus, i2c, or smbus-compatible master. the twis is always a bus slave and can transfer sequential or sin- gle bytes. below, table 28-1 lists the compatibility leve l of the atmel two-wire slav e interface and a full i2c compatible device. note: 1. start + b000000001 + ack + sr table 28-1. atmel twis compatibility with i2c standard i2c standard atmel twis standard-mode (100 kbit/s) supported fast-mode (400 kbit/s) supported high-speed-mode (3.4 mbit/s) supported 7 or 10 bits slave addressing supported start byte (1) not supported repeated start (sr) condition supported ack and nak management supported slope control and input filtering (fast mode) supported clock stretching supported
744 42023e?sam?07/2013 atsam4l8/l4/l2 below, table 28-2 lists the compatibility level of the atmel two-wire slave interface and a full smbus compatible device. 28.3 list of abbreviations 28.4 block diagram figure 28-1. block diagram table 28-2. atmel twis compatibilit y with smbus standard smbus standard atmel twis bus timeouts supported address resolution protocol supported packet error checking supported table 28-3. abbreviations abbreviation description twi two-wire interface a acknowledge na non acknowledge pstop sstart sr repeated start sadr slave address adr any address except sadr r read wwrite peripheral bus bridge two-wire interface i/o controller twck twd interrupt controller twi interrupt power manager clk_twis
745 42023e?sam?07/2013 atsam4l8/l4/l2 28.5 application block diagram figure 28-2. application block diagram 28.6 i/o lines description 28.7 product dependencies in order to use this module, other parts of the system must be configured correctly, as described below. 28.7.1 i/o lines twd and twck are bidirecti onal lines, connected to a positive supply voltage via a current source or pull-up resistor (see figure 28-5 on page 747 ). when the bus is free, both lines are high. the output stages of devices connected to the bus must have an open-drain or open-col- lector to perform the wired-and function. twd and twck pins may be multiplexed with i/o controller lines. to enable the twis, the user must perform the following steps: ? program the i/o controller to: ? dedicate twd, twckas peripheral lines. ? define twd, twckas open-drain. 28.7.2 power management if the cpu enters a sleep mode that disables cl ocks used by the twis, the twis will stop func- tioning and resume operation after the system wakes up from sleep mode. the twis is able to wake the system from sleep mode upon address match, see section 28.8.9 on page 754 . host with twi interface twd twck atmel twi serial eeprom i2c rtc i2c lcd controller slave 1 slave 2 slave 3 vdd i2c temp. sensor slave 4 rp: pull up value as given by the i2c standard rp rp table 28-4. i/o lines description pin name pin description type twd two-wire serial data input/output twck two-wire serial clock input/output
746 42023e?sam?07/2013 atsam4l8/l4/l2 28.7.3 clocks the clock for the twis bus interface (clk_twis) is generated by the power manager. it is rec- ommended to disable the twis before disabling the clock, to avoid freezing the twis in an undefined state. 28.7.4 dma the twis dma handshake interface is connected to the peripheral dma controller. using the twis dma functionality requires the peripheral dma controller to be programmed after setting up the twis. 28.7.5 interrupts the twis interrupt request lines are connected to the nvic. using the twis interrupts requires the nvic to be programmed first. 28.7.6 debug operation when an external debugger forces the cpu into debug mode, the twis continues normal oper- ation. if the twis is configured in a way that requires it to be periodically serviced by the cpu through interrupts or similar, improper operation or data loss may result during debugging. 28.8 functional description 28.8.1 transfer format the data put on the twd line must be 8 bits long. data is transferred msb first; each byte must be followed by an acknowledgement. the number of bytes per transfer is unlimited (see figure 28-4 on page 746 ). each transfer begins with a start condition and terminates with a stop condition (see figure 28-3 ). ? a high-to-low transition on the twd line while twck is high defines the start condition. ? a low-to-high transition on the twd line while twck is high defines a stop condition. figure 28-3. start and stop conditions figure 28-4. transfer format twd twck start stop twd twck start address r/w ack data ack data ack stop
747 42023e?sam?07/2013 atsam4l8/l4/l2 28.8.2 operation the twis has two modes of operation: ? slave transmitter mode ? slave receiver mode a master is a device which starts and stops a transfer and generates the twck clock. a slave is assigned an address and responds to requests from the master. these modes are described in the following chapters. figure 28-5. typical application block diagram 28.8.3 high-speed-mode after reset and initialization, the twis is either in standard-mode, fast-mode, or fast-mode plus (collectively referred to as the f/s -mode). the twis automatically enters high-speed- mode (hs-mode) after it detects the following c onditions (all of which are in f/s-mode) on the bus: 1. start condition (s) 2. 8-bit master code (0000 1xxx) 3. not-acknowledge bit (na) after the twis has detected the above conditions and before the commencement of hs-mode transfer, it do es the following: 1. adapts the twd and twck input filters to the spike suppression requirement in hs- mode. 2. adapts the twd output stage to the slope control requirement in hs-mode. the twis automatically returns to f/s-mode after it detects a stop condition on the bus. with regard to the slope control of the twd output, the user can control the fall times of the twd output in f/s- and hs-mode by writing to the data drive strength low (dadrivel) and data slew limit (daslew) fields in the sl ew rate register (srr) and hs-mode slew rate register (hssrr), respectively. refer to section 42. ?electrical characteristics? on page 1120 for appropriate values of these register fields. note that the fall times of the twd output are also controlled by the corresponding register fields in the two-wire master interface (twim) module. in order to correctly control the slew rate of the twd output, the user must either host with twi interface twd twck atmel twi serial eeprom i2c rtc i2c lcd controller slave 1 slave 2 slave 3 vdd i2c temp. sensor slave 4 rp: pull up value as given by the i2c standard rp rp
748 42023e?sam?07/2013 atsam4l8/l4/l2 ? write to the relevant register fields in the twis with appropriate values and leave those in twim as zeros, or vice versa; or ? write to the relevant register fields in both the twim and the twis with the same values. 28.8.3.1 bus timing the timing register (tr) is used to control the timing of bus signals driven by the twis. tr describes bus timings as a function of cycles of the prescaled clk_twis. the clock prescaling can be selected through tr.exp. tr has the following fields: tlows: prescaled clock cycles used to time smbus timeout t low:sext . ttout: prescaled clock cycles us ed to time smbus timeout t timeout . sudat: non-prescaled clock cycles for data setup and hold count. used to time t su_dat . exp: specifies the clock prescaler setting used for the smbus timeouts. when the twis is in hs-mode, the data hold count is set by writing to the hddat field in the hs-mode timing register (hstr). figure 28-6. bus timing diagram f prescaled f clk_twis 2 exp 1 + () ------------------------ - = s t hd:sta t low t su:dat t high t hd:dat t low p t su:sto sr t su:sta t su:dat
749 42023e?sam?07/2013 atsam4l8/l4/l2 28.8.3.2 setting up and performing a transfer operation of the twis is mainly controlled by the control register (cr) . the following list pres- ents the main steps in a typical communication: 1. before any transfers can be performed, bus timings must be configured by writing to the timing register (tr) and, if hs-mode transfer is supported, the hs-mode timing reg- ister (hstr). 2. if the peripheral dma controller is to be used for the transfers, it must be set up. 3. the control register (cr) must be configured with information such as the slave address, smbus mode, packet error checking (pec), number of bytes to transfer, and which addresses to match. the interrupt system can be set up to generate interrupt request on specific events or error con- ditions, for example when a byte has been received. the nbytes register is only used in smbus mode, when pec is enabled. in i2c mode or in smbus mode when pec is disabled, the nbytes register is not used, and should be written to zero. nbytes is updated by hardware, so in order to avoid hazards, software updates of nbytes can only be done through writes to the nbytes register. 28.8.3.3 address matching the twis can be set up to match several different addresses. more than one address match may be enabled simultaneously, allowing the twis to be assigned to several addresses. the address matching phase is initiated after a st art or repeated start condition. when the twis receives an address that generates an addr ess match, an ack is automatically returned to the master. in i2c mode: ? the address in cr.adr is checked fo r address match if cr.smatch is one. ? the general call address is checked fo r address match if cr.gcmatch is one. in smbus mode: ? the address in cr.adr is checked fo r address match if cr.smatch is one. ? the alert response address is checked for address match if cr.smal is one. ? the default address is checked for address match if cr.smda is one. ? the host header address is checked for address match if cr.smhh is one. 28.8.3.4 clock stretching any slave or bus master taking part in a transfer may extend the twck low period at any time. the twis may extend the twck low period afte r each byte transfer if cr.stren is one and: ? module is in slave transmitter mode, data should be transmitted, but thr is empty, or ? module is in slave receiver mode, a byte has been received and placed into the internal shifter, but the receive holdin g register (rhr) is full, or ? stretch-on-address-match bit cr.soam=1 and slave was addressed. bus clock remains stretched until all address match bits in the status register (sr) have been cleared. if cr.stren is zero and: ? module is in slave transmitter mode, data shou ld be transmitted but thr is empty: transmit the value present in thr (the last transmitted byte or reset value), and set sr.urun.
750 42023e?sam?07/2013 atsam4l8/l4/l2 ? module is in slave receiver mode, a byte has been received and placed into the internal shifter, but rhr is full: discard the received byte and set sr.orun. 28.8.3.5 bus errors if a bus error (misplaced start or stop) cond ition is detected, the sr.buserr bit is set and the twis waits for a new start condition. 28.8.4 slave transmitter mode if the twis matches an address in which the r/w bit in the twi address phase transfer is set, it will enter slave transmitter mode and set the sr.tra bit (note that sr.tra is set one clk_twis cycle after the relevant address match bit in the same register is set). after the address phase, the following actions are performed: 1. if smbus mode and pec is used, nbytes must be set up with the number of bytes to transmit. this is necessary in order to know when to transmit the pec byte. nbytes can also be used to count the number of bytes received if using dma. 2. byte to transmit depends on i2c/smbus mode and cr.pec: ? if in i2c mode or cr.pec is zero or n bytes is non-zero: the twis waits until thr contains a valid data byte, possibly stretching the low period of twck. after thr contains a valid data byte, the data byte is transferred to a shifter, and then sr.txrdy is changed to one be cause the thr is empty again. ? smbus mode and cr.pec is one: if nbytes is zero, the generated pec byte is automatically transmitted in stead of a data byte from thr. twck will not be stretched by the twis. 3. the data byte in the shifter is transmitted. 4. nbytes is updated. if cr.cup is one, nbyt es is incremented, otherwise nbytes is decremented. 5. after each data byte has been transmitted, the master transmits an ack (acknowledge) or nak (not acknowledge) bit. if a nak bit is received by the twis, the sr.nak bit is set. note that this is done two clk_twis cycles after twck has been sampled by the twis to be high (see figure 28-9 ). the nak indicates that the transfer is finished, and the twis will wait for a stop or repeated start. if an ack bit is received, the sr.nak bit remains low. the ack indicates that more data should be transmitted, jump to step 2. at the end of the ack/nak clock cycle, the byte transfer finished (sr.btf) bit is set. note that this is done two clk_twis cycles after twck has been sampled by the twis to be low (see figure 28-9 ). also note that in the event that sr.nak bit is set, it must not be cleared be fore the sr.btf bit is set to ensure correct twis behavior. 6. if stop is received, sr.tcomp and sr.sto will be set. 7. if repeated start is received, sr.rep will be set. the twi transfers require the receiver to acknowledge each received data byte. during the acknowledge clock pulse (9th pulse), the slave releases the data line (high), enabling the mas- ter to pull it down in order to generate the acknowledge. the slave polls the data line during this clock pulse and sets the nak bit in sr if the ma ster does not acknowledge the data byte. a nak means that the master does not wish to receive additional data bytes. as with the other status bits, an interrupt can be generated if enabled in the interrupt enable register (ier). sr.txrdy is used as transmit ready for the peripheral dma controller transmit channel.
751 42023e?sam?07/2013 atsam4l8/l4/l2 the end of the complete transfer is marked by the sr.tcomp bit changing from zero to one. see figure 28-7 and figure 28-8 . figure 28-7. slave transmitter with one data byte figure 28-8. slave transmitter with multiple data bytes figure 28-9. timing relationship between twck, sr.nak, and sr.btf 28.8.5 slave receiver mode if the twis matches an address in which the r/w bit in the twi address phase transfer is cleared, it will enter slave receiver mode and cl ear sr.tra (note that sr.tra is cleared one clk_twis cycle after the relevant address match bit in the same register is set). after the address phase, the following is repeated: tcomp txrdy write thr (data) stop sent by master twd adatan sdadrr p nbytes set to 1 adata na sdadrr data n+5a p data n+m n tco m p txrdy write thr (data n) nbytes set to m stop sent by master twd write thr (data n+1) write thr (data n+m) last data sent data (lsb) n p twck sr.nak sr.btf t 1 t 1 t 1 : (clk_twis period) x 2 twd
752 42023e?sam?07/2013 atsam4l8/l4/l2 1. if smbus mode and pec is used, nbytes must be set up with the number of bytes to receive. this is necessary in order to know which of the received bytes is the pec byte. nbytes can also be used to count the number of bytes received if using dma. 2. receive a byte. set sr.btf when done. 3. update nbytes. if cr.cup is written to one, nbytes is incremented, otherwise nbytes is decremented. nbytes is usually configured to count downwards if pec is used. 4. after a data byte has been received, the slave transmits an ack or nak bit. for ordi- nary data bytes, the cr.ack field controls if an ack or nak should be returned. if pec is enabled and the last byte received was a pec byte (indicated by nbytes equal to zero), the twis will automatically return an ack if the pec value was correct, other- wise a nak will be returned. 5. if stop is received, sr.tcomp will be set. 6. if repeated start is received, sr.rep will be set. the twi transfers require the receiver to acknowledge each received data byte. during the acknowledge clock pulse (9th pulse), the master releases the data line (high), enabling the slave to pull it down in order to generate the acknowledge. the master polls the data line during this clock pulse. the sr.rxrdy bit indicates that a data byte is available in the rhr. the rxrdy bit is also used as receive ready for the peripheral dma controller receive channel. figure 28-10. slave receiver with one data byte figure 28-11. slave receiver with multiple data bytes 28.8.6 interactive acking received data bytes when implementing a register interface over twi, it may sometimes be necessary or just useful to report reads and writes to invalid register addresses by sending a nak to the host. to be able to do this, one must first receive the register address from the twi bus, and then tell the twis a sdadrw data ap tcomp rx r dy read rhr twd a a sdadrw data na a data (n+1) a data (n+m) dat a (n+m)-1 p twd tco m p rx r dy read rhr data n read rhr dat a (n+1) read rhr dat a (n+m)-1 read rhr data (n+m)
753 42023e?sam?07/2013 atsam4l8/l4/l2 whether to ack or nak it. in normal operation of the twis, this is not possible because the con- troller will automatically ack the byte at about the same time as the rxrdy bit changes from zero to one. writing a one to the stretch on data byte received bit (cr.sodr) will stretch the clock allowing the user to update cr.ack bit before returning the desired value. after the last bit in the data byte is received, the twi bus clock is stretched, the received data byte is transferred to the rhr register, and sr.btf is set. at this time, the user can examine the received byte and write the desired ack or nack value to cr.a ck. when the user clears sr.btf, the desired ack value is transferred on the twi bus. this makes it possible to look at the byte received, determine if it is valid, and then decide to ack or nak it. 28.8.7 using the peripheral dma controller the use of the peripheral dma controller signifi cantly reduces the cpu load. the user can set up ring buffers for the peripheral dma controller, containing data to transmit or free buffer space to place received data. by initializing nbytes to zero before a transfer, and writing a one to cr.cup, nbytes is incremented by one each time a data has been transmitted or received. this allows the user to detect how much data was actually transferred by the dma system. to assure correct behavior, respect the following programming sequences: 28.8.7.1 data transmit with the peripheral dma controller 1. initialize the transmit peripheral dma controller (memory pointers, size, etc.). 2. configure the twis (adr, nbytes, etc.). 3. start the transfer by enabling the peripheral dma controller to transmit. 4. wait for the peripheral dma controller end-of-transmit flag. 5. disable the peripheral dma controller. 28.8.7.2 data receive with th e peripheral dma controller 1. initialize the receive peripheral dma controller (memory pointers, size - 1 , etc.). 2. configure the twis (adr, nbytes, etc.). 3. start the transfer by enabling the peripheral dma controller to receive. 4. wait for the peripheral dma controller end-of-receive flag. 5. disable the peripheral dma controller. 28.8.8 smbus mode smbus mode is enabled by writing a one to the smbus mode enable (smen) bit in cr. smbus mode operation is similar to i2c ope ration with the following exceptions: ? only 7-bit addressing can be used. ? the smbus standard describes a set of timeout values to ensure progress and throughput on the bus. these timeout values must be written to tr. ? transmissions can optionally include a crc byte, called packet error check (pec). ? a set of addresses have been reserved for protocol handling, such as alert response address (ara) and host header (hh) addres s. address matching on these addresses can be enabled by configuring cr appropriately. 28.8.8.1 packet error checking (pec) each smbus transfer can optionally end with a crc byte, called the pec byte. writing a one to the packet error checking enable (pecen) bit in cr enables automatic pec handling in the
754 42023e?sam?07/2013 atsam4l8/l4/l2 current transfer. the pec generator is always updated on every bit transmitted or received, so that pec handling on following linked transfers will be correct. in slave receiver mode, the master calculates a pec value and transmits it to the slave after all data bytes have been tr ansmitted. upon reception of this pec byte, the slave will compare it to the pec value it has computed itself. if the values match, the data was received correctly, and the slave will return an ack to th e master. if the pec values differ, data was corrupted, and the slave will return a nak value. the sr.smbpece rr bit is set automatically if a pec error occurred. in slave transmitter mode, the slave calculates a pec value and transmits it to the master after all data bytes have been transm itted. upon reception of this pec byte, the master will compare it to the pec value it has computed itself. if the values match, the data was received correctly. if the pec values differ, data was corrupted, and the master must take appropriate action. the pec byte is automatically inserted in a slave transmitter transmission if pec enabled when nbytes reaches zero. the pec byte is identified in a slave receiver transmission if pec enabled when nbytes reaches zero. nbytes must therefore be set to the total number of data bytes in the transmission, including the pec byte. 28.8.8.2 timeouts the timing register (tr) configures the smbus timeout values. if a timeout occurs, the slave will leave the bus. the sr.smbtout bit is also set. 28.8.9 wakeup from sleep modes by twi address match the twis is able to wake the device up from a sleep mode upon an address match, including sleep modes where clk_twis is stopped. after detecting the start condition on the bus, the twis will stretch twck until clk_twis has star ted. the time required for starting clk_twis depends on which sleep mode the device is in. after clk_twis has started, the twis releases its twck stretching and receives one byte of data on the bus. at this time, only a limited part of the device, including the twis, receives a cloc k, thus saving power. if the received byte is a master code, the twis enters hs-mode. the twis goes on to receive the slave address. if the address phase causes a twis address match, the entire device is wakened and normal twis address matching actions are performed. normal twi transfer then follows. if the twis is not addressed, clk_twis is automatically stopped and the device immediately returns to its origi- nal sleep mode. if the twis is in hs-mode, it remains so until it detects a stop condition on the bus, after which it swit ches back to f/s-mode.
755 42023e?sam?07/2013 atsam4l8/l4/l2 28.8.10 identifying bus events this chapter lists the different bus events, and how these affects the bits in the twis registers. this is intended to help wr iting drivers for the twis. table 28-5. bus events event effect slave transmitter has sent a data byte sr.thr is cleared. sr.btf is set. the value of the ack bit sent immediately after the data byte is given by cr.ack. slave receiver has received a data byte sr.rhr is set. sr.btf is set. sr.nak updated according to value of ack bit received from master. start+sadr on bus, but address is to another slave none. start+sadr on bus, current slave is addressed, but address match enable bit in cr is not set none. start+sadr on bus, current slave is addressed, corresponding address match enable bit in cr set correct address match bit in sr is set. sr.tra updated according to transfer direction (updating is done one clk_twis cycle af ter address match bit is set) slave enters appropriate transfer direction mode and data transfer can commence. start+sadr on bus, current slave is addressed, corresponding address match enable bit in cr set, sr.stren and sr.soam are set. correct address match bit in sr is set. sr.tra updated according to transfer direction (updating is done one clk_twis cycle af ter address match bit is set). slave stretches twck immediately after transmitting the address ack bit. twck remains stretched until all address match bits in sr have been cleared. slave enters appropriate transfer direction mode and data transfer can commence. repeated start received after being addressed sr.rep set. sr.tcomp unchanged. stop received after being addressed sr.sto set. sr.tcomp set. start, repeated start, or stop received in illegal position on bus sr.buserr set. sr.sto and sr.tcomp may or may not be set depending on the exact position of an illegal stop. data is to be received in slave receiver mode, sr.stren is set, and rhr is full twck is stretched until rhr has been read. data is to be transmitted in slave receiver mode, sr.stren is set, and thr is empty twck is stretched until thr has been written.
756 42023e?sam?07/2013 atsam4l8/l4/l2 data is to be received in slave receiver mode, sr.stren is cleared, and rhr is full twck is not stretched, read data is discarded. sr.orun is set. data is to be transmitted in slave receiver mode, sr.stren is cleared, and thr is empty twck is not stretched, previous c ontents of thr is written to bus. sr.urun is set. smbus timeout received sr.smbtout is set. twck and twd are immediately released. slave transmitter in smbus pec mode has transmitted a pec byte, that was not identical to the pec calculated by the master receiver. master receiver will transmit a nak as usual after the last byte of a master receiver transfer. master receiver will retry th e transfer at a later time. slave receiver discovers smbus pec error sr.smbpecerr is set. nak returned after the data byte. table 28-5. bus events event effect
757 42023e?sam?07/2013 atsam4l8/l4/l2 28.9 user interface note: 1. the reset values for these registers are device specific. refer to the module configuration section at the end of this c hapter. table 28-6. twis register memory map offset register register name access reset 0x00 control register cr read/write 0x00000000 0x04 nbytes register nbytes read/write 0x00000000 0x08 timing register tr read/write 0x00000000 0x0c receive holding register rhr read-only 0x00000000 0x10 transmit holding register thr write-only 0x00000000 0x14 packet error check register pecr read-only 0x00000000 0x18 status register sr read-only 0x00000002 0x1c interrupt enable register ier write-only 0x00000000 0x20 interrupt disable register idr write-only 0x00000000 0x24 interrupt mask register imr read-only 0x00000000 0x28 status clear register scr write-only 0x00000000 0x2c parameter register pr read-only - (1) 0x30 version register vr read-only - (1) 0x34 hs-mode timing register hstr read/write 0x00000000 0x38 slew rate register srr read/write 0x00000000 0x3c hs-mode slew rate register hssrr read/write 0x00000000
758 42023e?sam?07/2013 atsam4l8/l4/l2 28.9.1 control register name: cr access type: read/write offset :0x00 reset value: 0x00000000 ? tenbit: ten bit address match 0: disables ten bit address match. 1: enables ten bit address match. ? adr: slave address slave address used in slave address match. bits 9: 0 are used if in 10-bit mode, bits 6:0 otherwise. ? sodr: stretch clock on data byte reception 0: does not stretch bus clock immediately before acking a received data byte. 1: stretches bus clock immediately before acking a received data byte. ? soam: stretch clock on address match 0: does not stretch bus clock after address match. 1: stretches bus clock after address match. ? cup: nbytes count up 0: causes nbytes to count down (decrement) per byte transferred. 1: causes nbytes to count up (increment) per byte transferred. ? ack: slave receiver data phase ack value 0: causes a low value to be returned in the ack cycle of the data phase in slave receiver mode. 1: causes a high value to be returned in the ack cycle of the data phase in slave receiver mode. ? pecen: packet error checking enable 0: disables smbus pec (crc) generation and check. 1: enables smbus pec (crc) generation and check. ? smhh: smbus host header 0: causes the twis not to ackn owledge the smbus host header. 1: causes the twis to acknowledge the smbus host header. ? smda: smbus default address 0: causes the twis not to ackn owledge the smbus default address. 1: causes the twis to acknowledge the smbus default address. ? swrst: software reset this bit will always read as 0. writing a zero to this bit has no effect. 31 30 29 28 27 26 25 24 -----tenbit adr[9:8] 23 22 21 20 19 18 17 16 adr[7:0] 15 14 13 12 11 10 9 8 sodr soam cup ack pecen smhh smda - 76543210 swrst - - stren gcmatch smatch smen sen
759 42023e?sam?07/2013 atsam4l8/l4/l2 writing a one to this bit resets the twis. ? stren: clock stretch enable 0: disables clock stretching if rhr/thr bu ffer full/empty. may cause over/underrun. 1: enables clock stretching if rhr/thr buffer full/empty. ? gcmatch: general call address match 0: causes the twis not to ackn owledge the general call address. 1: causes the twis to ackno wledge the general call address. ? smatch: slave address match 0: causes the twis not to acknowledge the slave address. 1: causes the twis to acknowledge the slave address. ? smen: smbus mode enable 0: disables smbus mode. 1: enables smbus mode. ? sen: slave enable 0: disables the slave interface. 1: enables the slave interface.
760 42023e?sam?07/2013 atsam4l8/l4/l2 28.9.2 nbytes register name: nbytes access type: read/write offset :0x04 reset value: 0x00000000 ? nbytes: number of bytes to transfer writing to this field updates the nbytes counter. the field can also be read to learn the progress of the transfer. nbytes can be incremented or decremented automatically by hardware. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------- 76543210 nbytes
761 42023e?sam?07/2013 atsam4l8/l4/l2 28.9.3 timing register name: tr access type: read/write offset :0x08 reset value: 0x00000000 ? exp: clock prescaler used to specify how to prescale the smbus tlows counter. the counter is prescaled according to the following formula: ? sudat: data setup cycles non-prescaled clock cycles for data setup count. used to time t su_dat . data is driven sudat cycles after twck low detected. this timing is used for timing the ack/nak bits, and any data bits driven in slave transmitter mode. ?ttout: smbus t timeout cycles prescaled clock cycles used to time smbus t timeout . ?tlows: smbus t low:sext cycles prescaled clock cycles used to time smbus t low:sext . 31 30 29 28 27 26 25 24 exp ---- 23 22 21 20 19 18 17 16 sudat 15 14 13 12 11 10 9 8 ttout 76543210 tlows f prescaled f clk_twis 2 exp 1 + () ------------------------ - =
762 42023e?sam?07/2013 atsam4l8/l4/l2 28.9.4 receive holding register name: rhr access type: read-only offset :0x0c reset value: 0x00000000 ? rxdata: received data byte when the rxrdy bit in the status regist er (sr) is one, this field contains a byte received from the twi bus. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------- 76543210 rxdata
763 42023e?sam?07/2013 atsam4l8/l4/l2 28.9.5 transmit holding register name: thr access type: write-only offset :0x10 reset value: 0x00000000 ? txdata: data byte to transmit write data to be transf erred on the twi bus here. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------- 76543210 txdata
764 42023e?sam?07/2013 atsam4l8/l4/l2 28.9.6 packet error check register name: pecr access type: read-only offset :0x14 reset value: 0x00000000 ? pec: calculated pec value the calculated pec value. updated automatical ly by hardware after each byte has been transferred. reset by hardware after a stop condition. provided if the user manu ally wishes to control when the pec byte is transmitted, or wishes to access the pec value for other reasons. in ordinary operation, the pec handling is done automatically by hardware. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------- 76543210 pec
765 42023e?sam?07/2013 atsam4l8/l4/l2 28.9.7 status register name: sr access type: read-only offset :0x18 reset value: 0x000000002 ? btf: byte transfer finished this bit is cleared when the corresponding bit in scr is written to one. this bit is set when byte transfer has completed. ? rep: repeated start received this bit is cleared when the corresponding bit in scr is written to one. this bit is set when a repeate d start condition is received. ? sto: stop received this bit is cleared when the corresponding bit in scr is written to one. this bit is set when the stop condition is received. ? smbdam: smbus default address match this bit is cleared when the corresponding bit in scr is written to one. this bit is set when the received address matched the smbus default address. ? smbhhm: smbus host header address match this bit is cleared when the corresponding bit in scr is written to one. this bit is set when the received address matched the smbus host header address. ? gcm: general call match this bit is cleared when the corresponding bit in scr is written to one. this bit is set when the received address matched the general call address. ? sam: slave address match this bit is cleared when the corresponding bit in scr is written to one. this bit is set when the received address matched the slave address. ? buserr: bus error this bit is cleared when the corresponding bit in scr is written to one. this bit is set when a misplaced start or stop condition has occurred. ? smbpecerr: smbus pec error this bit is cleared when the corresponding bit in scr is written to one. this bit is set when a smbus pec error has occurred. 31 30 29 28 27 26 25 24 -- - ----- 23 22 21 20 19 18 17 16 btf rep sto smbdam smbhhm - gcm sam 15 14 13 12 11 10 9 8 - buserr smbpecerr smbtout - - - nak 76 5 43210 orun urun tra - tcomp sen txrdy rxrdy
766 42023e?sam?07/2013 atsam4l8/l4/l2 ? smbtout: smbus timeout this bit is cleared when the corresponding bit in scr is written to one. this bit is set when a smbus timeout has occurred. ? nak: nak received this bit is cleared when the corresponding bit in scr is written to one. this bit is set when a nak was received from the master during slave transmitter operation. ? orun: overrun this bit is cleared when the corresponding bit in scr is written to one. this bit is set when an overrun has occurred in slave receiver mode. can only occur if cr.stren is zero. ? urun: underrun this bit is cleared when the corresponding bit in scr is written to one. this bit is set when an underrun has occurred in slave transmitter mode. can only occur if cr.stren is zero. ? tra: transmitter mode 0: the slave is in slave receiver mode. 1: the slave is in slave transmitter mode. ? tcomp: transmis sion complete this bit is cleared when the corresponding bit in scr is written to one. this bit is set when transmission is complete. set after receiving a stop after being addressed. ? sen: slave enabled 0: the slave interface is disabled. 1: the slave interface is enabled. ? txrdy: tx buffer ready 0: the tx buffer is full and should not be written to. 1: the tx buffer is empty, and can accept new data. ? rxrdy: rx buffer ready 0: no rx data ready in rhr. 1: rx data is ready to be read from rhr.
767 42023e?sam?07/2013 atsam4l8/l4/l2 28.9.8 interrupt enable register name: ier access type: write-only offset :0x1c reset value: 0x00000000 writing a zero to a bit in this register has no effect. writing a one to a bit in this register will write a one to the corresponding bit in imr. 31 30 29 28 27 26 25 24 -- - ----- 23 22 21 20 19 18 17 16 btf rep sto smbdam smbhhm - gcm sam 15 14 13 12 11 10 9 8 - buserr smbpecerr smbtout - - - nak 76 5 43210 orun urun - - tcomp - txrdy rxrdy
768 42023e?sam?07/2013 atsam4l8/l4/l2 28.9.9 interrupt disable register name: idr access type: write-only offset :0x20 reset value: 0x00000000 writing a zero to a bit in this register has no effect. writing a one to a bit in this register will clear the corresponding bit in imr. 31 30 29 28 27 26 25 24 -- - ----- 23 22 21 20 19 18 17 16 btf rep sto smbdam smbhhm - gcm sam 15 14 13 12 11 10 9 8 - buserr smbpecerr smbtout - - - nak 76 5 43210 orun urun - - tcomp - txrdy rxrdy
769 42023e?sam?07/2013 atsam4l8/l4/l2 28.9.10 interrupt mask register name: imr access type: read-only offset :0x24 reset value: 0x00000000 0: the corresponding interrupt is disabled. 1: the corresponding interrupt is enabled. this bit is cleared when the corresponding bit in idr is written to one. this bit is set when the corresponding bit in ier is written to one. 31 30 29 28 27 26 25 24 -- - ----- 23 22 21 20 19 18 17 16 btf rep sto smbdam smbhhm - gcm sam 15 14 13 12 11 10 9 8 - buserr smbpecerr smbtout - - - nak 76 5 43210 orun urun - - tcomp - txrdy rxrdy
770 42023e?sam?07/2013 atsam4l8/l4/l2 28.9.11 status clear register name: scr access type: write-only offset :0x28 reset value: 0x00000000 writing a zero to a bit in this register has no effect. writing a one to a bit in this register will clear the corresponding bit in sr and the corresponding interrupt request. 31 30 29 28 27 26 25 24 -- - ----- 23 22 21 20 19 18 17 16 btf rep sto smbdam smbhhm - gcm sam 15 14 13 12 11 10 9 8 - buserr smbpecerr smbtout - - - nak 76 5 43210 orun urun - - tcomp - - -
771 42023e?sam?07/2013 atsam4l8/l4/l2 28.9.12 parameter register name: pr access type: read-only offset :0x2c reset value: - ?hs: hs-mode 0: high-speed-mode is not supported. 1: high-speed-mode is supported. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------- 76543210 -------hs
772 42023e?sam?07/2013 atsam4l8/l4/l2 28.9.13 version register name: vr access type: read-only offset: 0x30 reset value: - ? variant: variant number reserved. no functionality associated. ? version: version number version number of the module. no functionality associated. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 ---- variant 15 14 13 12 11 10 9 8 ---- version [11:8] 76543210 version [7:0]
773 42023e?sam?07/2013 atsam4l8/l4/l2 28.9.14 hs-mode timing register name: hstr access type: read/write offset :0x34 reset value: 0x00000000 ? hddat: data hold cycles non-prescaled clock cycles for data hold count wh en the twis is in hs-mode. used to time t hd_dat . data is driven hddat cycles after a low on twck is detected. this timi ng is used for timing the ack/nak bits, and any data bits driven in slave transmitter mode. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 hddat 15 14 13 12 11 10 9 8 -------- 76543210 --------
774 42023e?sam?07/2013 atsam4l8/l4/l2 28.9.15 slew rate register name: srr access type: read/write offset :0x38 reset value: 0x00000000 ? filter: input spike filter control ? daslew: data slew limit selects the slew limit of the twd output buffer in f/s-mode. ? dadrivel: data drive strength low selects the pull-down drive strength of the twd output buffer in f/s-mode. refer to section 42. ?electrical characteristics? on page 1120 for appropriates values of these register fields. 31 30 29 28 27 26 25 24 -- filter ---- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 ------ daslew 76543210 ----- dadrivel filter value function 0reserved 1reserved 2 standard- or fast-mode 3 fast-mode plus
775 42023e?sam?07/2013 atsam4l8/l4/l2 28.9.16 hs-mode slew rate register name: hssrr access type: read/write offset :0x3c reset value: 0x00000000 ? filter: input spike filter control ? daslew: data slew limit selects the slew limit of the twd output buffer in hs-mode. ? dadrivel: data drive strength low selects the pull-down drive strength of the twd output buffer in hs-mode. refer to section 42. ?electrical characteristics? on page 1120 for appropriates values of these register fields. 31 30 29 28 27 26 25 24 -- filter ---- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 ------ daslewl 76543210 ----- dadrivel filter value function 0reserved 1 hs-mode 2reserved 3reserved
776 42023e?sam?07/2013 atsam4l8/l4/l2 28.10 module configuration the specific configuration for each twis instance is listed in the following tables.the module bus clocks listed here are connected to the system bus clocks. refer to section 10. ?power man- ager (pm)? on page 108 for details. note : twi2 and twi3 are master only. twi0 and twi1 are master and slave table 28-7. module clock name module name clock name description twis0 clk_twis0 clock for the twis0 bus interface twis1 clk_twis1 clock for the twis1 bus interface table 28-8. register reset values register reset value version 0x00000140 parameter 0x00000001
777 42023e?sam?07/2013 atsam4l8/l4/l2 29. inter-ic sound controller (iisc) rev: 1.0.0.0 29.1 features ? compliant with inter-ic sound (i 2 s) bus specification ? master, slave, and controller modes: ? slave: data received/transmitted ? master: data received/transmitted and clocks generated ? controller: clocks generated ? individual enable and disable of receiver, transmitter, and clocks ? configurable clock generator comm on to receiver and transmitter: ? suitable for a wide range of sample frequenc ies (fs), including 32khz, 44.1khz, 48khz, 88.2khz, 96khz, and 192khz ? 16fs to 1024fs master clock generated for external oversampling adcs ? several data formats supported: ? 32-, 24-, 20-, 18-, 16-, and 8-bit mono or stereo format ? 16- and 8-bit compact stereo format, with left and right samples packed in the same word to reduce data transfers ? dma interfaces for receiver and transmit ter to reduce processor overhead: ? either one dma channel for both audio channels, or ? one dma channel per audio channel ? smart holding registers management to avoid audio channels mix after overrun or underrun 29.2 overview the inter-ic sound controller (iisc) provides a 5-wire, bidirectional, synchronous, digital audio link with external audio devices: isdi , isdo, iws, isck, and imck pins. this controller is compliant with the inter-ic sound (i 2 s) bus specification. the iisc consists of a receiver, a transmitter, and a common clock generator, that can be enabled separately, to provide master, slave, or controller modes with receiver, transmitter, or both active. peripheral dma channels, separate for the receiver and for the transmitter, allow a continuous high bitrate data transfer without processor intervention to the following: ? audio codecs in master, slave, or controller mode ? stereo dac or adc through dedicated i 2 s serial interface the iisc can use either a single dma channel for both audio channels or one dma channel per audio channel. the 8- and 16-bit compact stereo format allows reducing the required dma bandwidth by trans- ferring the left and right samples within the same data word. in master mode, the iisc allows outputting a 16 fs to 1024fs master clock, in order to provide an oversampling clock to an external audio codec or digital signal processor (dsp).
778 42023e?sam?07/2013 atsam4l8/l4/l2 29.3 block diagram figure 29-1. iisc block diagram 29.4 i/o lines description 29.5 product dependencies in order to use this module, other parts of the system must be configured correctly, as described below. 29.5.1 i/o lines the iisc pins may be multiplexed with i/o contro ller lines. the user must first program the i/o controller to assign the desired iisc pins to their peripheral function. if the iisc i/o lines are not used by the application, they can be used for other purposes by the i/o controller. it is required to enable only the iisc inputs and outputs actually in use. 29.5.2 power management if the cpu enters a sleep mode th at disables clocks used by the iisc, the iisc will stop function- ing and resume operation after the system wakes up from sleep mode. i/o controller isck iws isdi isdo imck receiver clocks transmitter peripheral bus interface generic clock pb peripheral bus bridge interrupt controller scif power manager pb clock irq peripheral dma controller rx tx iisc table 29-1. i/o lines description pin name pin description type imck master clock output isck serial clock input/output iws i 2 s word select input/output isdi serial data input input isdo serial data output output
779 42023e?sam?07/2013 atsam4l8/l4/l2 29.5.3 clocks the clock for the iisc bus interface (clk_iisc) is generated by the power manager. it is recom- mended to disable the iisc before disabling the cl ock, to avoid freezing the iisc in an undefined state. one of the generic clocks is connected to the iisc. the generic clock (gclk_iisc) can be set to a wide range of frequencies and clock sources. the gclk_iisc must be enabled and config- ured before use. refer to the module configuration section for details on the gclk_iisc used for the iisc. the frequency for this clock has to be set as described in table. 29.5.4 dma the iisc dma handshake interfaces are connected to the peripheral dma controller. using the iisc dma functionality requires the peripheral dma controller to be programmed first. 29.5.5 interrupts the iisc interrupt line is connected to the interrupt controller. using the iisc interrupt requires the interrupt controller to be programmed first. 29.5.6 debug operation when an external debugger forces the cpu into debug mode, the iisc continues normal opera- tion. if this module is configured in a way that requires it to be periodically serviced by the cpu through interrupt requests or similar, improper operation or data loss may result during debugging. 29.6 functional description 29.6.1 initialization the iisc features a receiver, a transmitter, and, for master and controller modes, a clock generator. receiver and transmitter share the same serial clock and word select. before enabling the iisc, the chosen configuration must be written to the mode register (mr). the imckmode, mode, and datalength fields in the mr register must be written. if the imckmode field is written as one, then the im ckfs field should be written with the chosen ratio, as described in section 29.6.5 ?serial clock and word select generation? on page 781 . once the mode register has been written, t he iisc clock generator, receiver, and transmitter can be enabled by writing a one to the cken, rx en, and txen bits in the control register (cr). the clock generator can be enabled alone, in controller mode, to output clocks to the imck, isck, and iws pins. the clock generator must also be enabled if the receiver or the transmitter is enabled. the clock generator, receiver, and transmitter can be disabled independently by writing a one to cr.cxdis, cr.rxdis and/or cr.txdis respec tively. once requested to stop, they will only stop when the transmission of the p ending frame transmi ssion will be completed. 29.6.2 basic operation the receiver can be operated by reading the receiver holding regist er (rhr), whenever the receive ready (rxrdy) bit in the status regist er (sr) is set. successive values read from rhr will correspond to the sample s from the left and right audi o channels for the successive frames.
780 42023e?sam?07/2013 atsam4l8/l4/l2 the transmitter can be operated by writing to t he transmitter holding register (rhr), when- ever the transmit ready (txrdy) bit in the stat us register (sr) is set. successive values written to thr should correspond to the samples from the left and right audio channels for the successive frames. the receive ready and transmit ready bits ca n be polled by reading the status register. the iisc processor load can be reduced by enabling interrupt-driven operation. the rxrdy and/or txrdy interrupt requests can be enabled by writing a one to the corresponding bit in the interrupt enable register (ier). the interrupt service routine associated to the iisc interrupt request will then be executed whenever the receiv e ready or the transmit ready status bit is set. 29.6.3 master, controller, and slave modes in master and controller modes, the iisc provi des the master clock, the serial clock and the word select. imck, isck, and iws pins are outputs. in controller mode, the iisc receiver and transmitter are disabled. only the clocks are enabled and used by an external receiver and/or transmitter. in slave mode, the iisc receives the serial clock and the word select from an external master. isck and iws pins are inputs. the mode is selected by writing the mode field of the mode register (mr). since the mode field changes the direction of the iws and isck pi ns, the mode register sh ould only be written when the iisc is stopped, in order to avoid unwanted glitches on the iws and isck pins. 29.6.4 i 2 s reception and transmission sequence as specified in the i 2 s protocol, data bits are left-adjusted in the word select time slot, with the msb transmitted first, starting one clock period after the transition on the word select line. figure 29-2. i 2 s reception and transmission sequence data bits are sent on the falling edge of the se rial clock and sampled on the rising edge of the serial clock. the word select line indicates t he channel in transmission, a low level for the left channel and a high level for the right channel. the length of transmitted words can be chosen among 8, 16, 18, 20, 24, and 32 bits by writing the mr.datalength field. if the time slot allows for more data bits t han written in the mr.datalength field, zeroes are appended to the transmitted data word or extra received bits are discarded. if the time slot allows for less data bits than written, the extra bits to be transmitted are not sent or the missing bits are set to zero in the received data word. serial clock isck word select iws data isdi/isdo msb left channel lsb msb right channel
781 42023e?sam?07/2013 atsam4l8/l4/l2 29.6.5 serial clock and word select generation the generation of clocks in the iisc is described in figure 29-3 on page 782 . in slave mode, the serial clock and word select clock are driven by an external master. isck and iws pins are inputs and no generic clock is required by the iisc. in master mode, the user can configure the master clock, serial clock, and word select clock through the mode register (mr). imck, isck, and iws pins are outputs and a generic clock is used to derive the iisc clocks. audio codecs connected to the iisc pins may require a master clock signal with a frequency multiple of the audio sample frequency (fs), such as 256fs. when the iisc is in master mode, writing a one to mr.imckmode will output gclk_i isc as master clock to the imck pin, and will divide gclk_iisc to create the internal bit cl ock, output on the isck pin. the clock division factor is defined by writing to mr.imckfs and mr.datalength, as described ?imckfs: master clock to fs ratio? on page 788 . the master clock (imck) frequency is 16*(imckfs+1) times the sample frequency (fs), i.e. iws frequency. the serial clock (isck) frequency is 2*slot length times the sample frequency (fs), where slot length is defined in table 29-2 on page 781 . warning: mr.imckmode shou ld only be written as one if the master clock frequency is strictly higher than the serial clock. if a master clock output is not required, the gclk _iisc generic clock is used as isck, by writ- ing a zero to mr.imckmode. alternatively, if the frequency of the generic clock used is a multiple of the required isck frequency, the imck to isck divider can be used with the ratio defined by writing the mr.imckfs field. the iws pin is used as word select as described in section 29.6.4 ?i2s reception and trans- mission sequence? on page 780 . table 29-2. slot length mr.datalength word length slot length 0 32 bits 32 1 24 bits 32 if mr.iws24 is zero 24 if mr.iws24 is one 2 20 bits 3 18 bits 4 16 bits 16 5 16 bits compact stereo 6 8 bits 8 7 8 bits compact stereo
782 42023e?sam?07/2013 atsam4l8/l4/l2 figure 29-3. iisc clocks generation 29.6.6 mono when the transmit mono (txmono) in the mode register is set, data written to the left channel is duplicated to the right output channel. when the receive mono (rxmono) in the mode r egister is set, data received from the left channel is duplicated to the right channel. 29.6.7 holding registers the iisc user interface includes a receive holding register (rhr) and a transmit holding register (thr). rhr and thr are used to access audio samples for both audio channels. when a new data word is available in the rhr r egister, the receive ready bit (rxrdy) in the status register (sr) is set. readin g the rhr register will clear this bit. a receive overrun condition occurs if a new da ta word becomes available before the previous data word has been read from the rhr register. then, the receive overrun bit in the status register will be set and bit i of the rxorch field in the status register is set, where i is the cur- rent receive channel number. when the thr register is empty, the transmit ready bit (txrdy) in the status register (sr) is set. writing into the thr re gister will clear this bit. a transmit underrun condition occurs if a new data word needs to be transmitted before it has been written to the thr register. then, the transmit underrun bit in the status register will be set and bit i of the txorch field in the status register is set, where i is the current transmit channel number. if the txsame bit in the mode register is zero, then a zero data word is trans- mitted in case of underrun. if mr.txsame is one, then the previous data word for the current transmit channel number is transmitted. mr.mode = slave clock divider mr.datalength gclk_iisc clock enable clock divider cr.cken/ckdis mr.imckmode mr.datalength mr.imckfs mr.imckmode 1 0 imck pin output clock enable cr.cken/ckdis internal bit clock isck pin input 1 0 isck pin output internal word clock iws pin input 1 0 iws pin output
783 42023e?sam?07/2013 atsam4l8/l4/l2 data words are right-justified in the rhr and thr registers. for 16-bit compact stereo, the left sample uses bits 15 through 0 and the right sample uses bits 31 through 16 of the same data word. for 8-bit compact stereo, the left sample uses bits 7 through 0 and the right sample uses bits 15 through 8 of the same data word. 29.6.8 dma operation the receiver and the transmitter can each be connected either to one single peripheral dma channel or to one peripheral dma channel per data channel. this is selected by writing to the mr.rxdma and mr.txdma bits. if a single peri pheral dma channel is selected, all data sam- ples use iisc receiver or transmitter dma channel 0. the peripheral dma reads from the rhr register and writes to the rhr register for both audio channels, successively. the peripheral dma transfers may use 32-bit word , 16-bit halfword, or 8-bit byte according to the value of the mr.datalength field. 29.6.9 loop-back mode for debugging purposes, the iisc can be configured to loop back the transmitter to the receiver. writing a one to the mr.loop bit will in ternally connect isdo to isdi, so that the transmitted data is also received. writing a zero to mr.loop will restore the normal behavior with independent receiver and transmitter. as for other changes to the receiver or transmitter configuration, the iisc receiver and transmitter must be disabled before writing to the mr reg- ister to update mr.loop. 29.6.10 interrupts an iisc interrupt request can be triggered whenever one or several of the following bits are set in the status register (sr) : receive ready (rxrdy), rece ive overrun (rxor), transmit ready (txrdy), or transmit underrun (txor). the interrupt request will be generated if the corresponding bit in the interrupt mask register (imr) is set. bits in imr are set by writing a one to the corresponding bit in the interrupt enable register (ier), and cleared by writing a one to the corresponding bit in the interrupt disable register (idr). the interrupt request remains acti ve until the corresponding bit in sr is cleared by writing a one the corresponding bit in the status clear register (scr). for debugging purposes, interrupt requests can be simulated by writing a one to the correspond- ing bit in the status set register (ssr).
784 42023e?sam?07/2013 atsam4l8/l4/l2 figure 29-4. interrupt block diagram 29.7 iisc application examples the iisc can support several serial communica tion modes used in audio or high-speed serial links. some standard applications are shown in t he following figures. all se rial link applications supported by the iisc are not listed here. figure 29-5. audio application block diagram imr ier idr clear set interrupt control iisc interrupt request txrdy txur transmitter receiver rxrdy rxor serial clock word select serial data out msb lsb msb serial data out word select serial clock iisc isck iws isdo isdi external i 2 s receiver
785 42023e?sam?07/2013 atsam4l8/l4/l2 figure 29-6. codec application block diagram figure 29-7. time slot application block diagram iisc word select serial data out serial data in external audio codec imck iws isdo isdi serial clock master clock isck right time slot serial clock word select serial data out serial data in dstart dend left time slot external audio codec for left time slot external audio codec for right time slot serial data in serial data out word select serial clock serial clock word select serial data out serial data in dstart left time slot right time slot dend iisc isck iws isdo isdi master clock imck
786 42023e?sam?07/2013 atsam4l8/l4/l2 29.8 user interface note: 1. the reset values for these registers are device specific. refer to the module configuration section at the end of this c hapter. table 29-3. iisc register memory map offset register register name access reset 0x00 control register cr write-only 0x00000000 0x04 mode register mr read/write 0x00000000 0x08 status register sr read-only 0x00000000 0x0c status clear register scr write-only 0x00000000 0x10 status set register ssr write-only 0x00000000 0x14 interrupt enable register ier write-only 0x00000000 0x18 interrupt disable register idr write-only 0x00000000 0x1c interrupt mask register imr read-only 0x00000000 0x20 receiver holding register rhr read-only 0x00000000 0x24 transmitter holding register thr write-only 0x00000000 0x28 version register version read-only - (1) 0x2c parameter register pa r a m e t e r read-only - (1)
787 42023e?sam?07/2013 atsam4l8/l4/l2 29.8.1 control register name: cr access type: write-only offset: 0x00 reset value: 0x00000000 the control register should only be written to enable the iisc after the chosen configuration has been written to the mode register, in order to avoid unwanted glitches on the iws, isck, and isdo outputs. the proper sequence is to write the mr register, then write the cr register to enable the iisc, or to disable the iisc before writing a new value into mr. ? swrst: software reset writing a zero to this bit has no effect. writing a one to this bit resets all the registers in the module. the module will be disabled after the reset. this bit always reads as zero. ? txdis: transmitter disable writing a zero to this bit has no effect. writing a one to this bit disables the iisc transmitter. sr.txen will be cleared when the transmitter is effectively stopped. ? txen: transmitter enable writing a zero to this bit has no effect. writing a one to this bit enables the iisc transmitter, if tx dis is not one. sr.txen will be set when the transmitter is effect ively started. ? ckdis: clocks disable writing a zero to this bit has no effect. writing a one to this bit disables the iisc clocks generation. ? cken: clocks enable writing a zero to this bit has no effect. writing a one to this bit enables the iisc clocks generation, if ckdis is not one. ? rxdis: receiver disable writing a zero to this bit has no effect. writing a one to this bit disables the iisc receiver. sr.txe n will be cleared when the transmitter is effectively stopped. ? rxen: receiver enable writing a zero to this bit has no effect. writing a one to this bit enables the iisc receiver, if rxdis is not one. sr.rxen will be set when the receiver is effectively started. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------- 76543210 swrst - txdis txen ckdis cken rxdis rxen
788 42023e?sam?07/2013 atsam4l8/l4/l2 29.8.2 mode register name: mr access type: read/write offset: 0x04 reset value: 0x00000000 the mode register should only be written when the iisc is stopped, in order to avoid unwanted glitches on the iws, isck, and isdo outputs. the proper sequence is to write the mr register, then write the cr register to enable the iisc, or to dis- able the iisc before writing a new value into mr. ? iws24: iws tdm slot width 0: iws slot is 32-bit wide for datalength=18/20/24-bit. 1: iws slot is 24-bit wide for datalength=18/20/24-bit. refer to table 29-2, ?slot length,? on page 781 . ? imckmode: master clock mode 0: no master clock generated (gener ic clock is used as isck output). 1: master clock generated (generic clock is used as imck output). warning: if imck frequency is the same as isck, imckmode should not be written as one. refer to section 29.6.5 ?serial clock and word select generation? on page 781 and table 29-2, ?slot length,? on page 781 . ? imckfs: master clock to fs ratio master clock frequency is 16*(imckfs+1) ti mes the sample rate, i.e. iws frequency: 31 30 29 28 27 26 25 24 iws24 imckmode imckfs 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 - txsame txdma txmono rxloop rxdma rxmono 76543210 --- datalength -mode table 29-4. master clock to sample frequency (fs) ratio fs ratio imckfs 16 fs 0 32 fs 1 48fs 2 64 fs 3 96fs 5 128 fs 7 192fs 11 256 fs 15
789 42023e?sam?07/2013 atsam4l8/l4/l2 ? txsame: transmit data when underrun 0: zero sample transmitted when underrun. 1: previous sample transmitted when underrun ? txdma: single or multiple dma channels for transmitter 0: transmitter uses a single dma channel for both audio channels. 1: transmitter uses one dma channel per audio channel. ? txmono: transmit mono 0: stereo. 1: mono, with left audio samples duplicated to right audio channel by the iisc. ? rxloop: loop-back test mode 0: normal mode. 1: isdo output of iisc is inte rnally connected to isdi input. ? rxmono: receive mono 0: stereo. 1: mono, with left audio samples duplicated to right audio channel by the iisc. ? rxdma: single or multiple dma channels for receiver 0: receiver uses a single dma channel for both audio channels. 1: receiver uses one dma channel per audio channel. ? datalength: data word length ?mode: mode 384 fs 23 512 fs 31 768 fs 47 1024 fs 63 table 29-5. data word length datalength word length comments 0 32 bits 1 24 bits 2 20 bits 3 18 bits 4 16 bits 5 16 bits compact stereo left sample in bits 15 through 0 and right sample in bits 31 through 16 of the same word 6 8 bits 7 8 bits compact stereo left sample in bits 7 through 0 and right sample in bits 15 through 8 of the same word table 29-6. mode mode comments 0 slave isck and iws pin inputs used as bit clock and word select/frame sync. 1 master bit clock and word select/frame sync generated by iisc from gclk_iisc and output to isck and iws pins. gclk_iisc is output as master clock on imck if mr.imckmode is one. table 29-4. master clock to sample frequency (fs) ratio fs ratio imckfs
790 42023e?sam?07/2013 atsam4l8/l4/l2 29.8.3 status register name: sr access type: read-only offset: 0x08 reset value: 0x00000000 ? txurch: transmit underrun channel this field is cleared when scr.txur is written to one. bit i of this field is set when a transmit underrun error occurred in channel i (i=0 for first channel of the frame). ? rxorch: receive overrun channel this field is cleared when scr.rxor is written to one. bit i of this field is set when a receive overrun error occurred in channel i (i=0 for first channel of the frame). ? txur: transmit underrun this bit is cleared when the corresponding bit in scr is written to one. this bit is set when an underrun error occurs on the thr register or when the corresponding bit in ssr is written to one. ? txrdy: transmit ready this bit is cleared when data is written to thr. this bit is set when the thr register is empty and can be written with new data to be transmitted. ? txen: transmitter enabled this bit is cleared when the transmitter is effectiv ely disabled, following a cr.txdis or cr.swrst request. this bit is set when the transmitter is effectively enabled, following a cr.txen request. ? rxor: receive overrun this bit is cleared when the corresponding bit in scr is written to one. this bit is set when an overrun error occurs on the rhr register or when the corresponding bit in ssr is written to one. ? rxrdy: receive ready this bit is cleared when the rhr register is read. this bit is set when received data is present in the rhr register. ? rxen: receiver enabled this bit is cleared when the receiver is effectivel y disabled, following a cr.rxdis or cr.swrst request. this bit is set when the receiver is effe ctively enabled, following a cr.rxen request. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 - - txurch - - - - 15 14 13 12 11 10 9 8 ------ rxorch 76543210 - txur txrdy txen - rxor rxrdy rxen
791 42023e?sam?07/2013 atsam4l8/l4/l2 29.8.4 status clear register name: scr access type: write-only offset: 0x0c reset value: 0x00000000 writing a zero to a bit in this register has no effect. writing a one to a bit in this register will clear the corresponding bit in sr and the corresponding interrupt request. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 - - txurch - - - - 15 14 13 12 11 10 9 8 ------ rxorch 76543210 -txur---rxor--
792 42023e?sam?07/2013 atsam4l8/l4/l2 29.8.5 status set register name: ssr access type: write-only offset: 0x10 reset value: 0x00000000 writing a zero to a bit in this register has no effect. writing a one to a bit in this register will set the corresponding bit in sr. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 - - txurch - - - - 15 14 13 12 11 10 9 8 ------ rxorch 76543210 -txur---rxor--
793 42023e?sam?07/2013 atsam4l8/l4/l2 29.8.6 interrupt enable register name: ier access type: write-only offset: 0x14 reset value: 0x00000000 writing a zero to a bit in this register has no effect. writing a one to a bit in this register will set the corresponding bit in imr. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------- 76543210 - txur txrdy - - rxor rxrdy -
794 42023e?sam?07/2013 atsam4l8/l4/l2 29.8.7 interrupt disable register name: idr access type: write-only offset: 0x18 reset value: 0x00000000 writing a zero to a bit in this register has no effect. writing a one to a bit in this register will clear the corresponding bit in imr. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------- 76543210 - txur txrdy - - rxor rxrdy -
795 42023e?sam?07/2013 atsam4l8/l4/l2 29.8.8 interrupt mask register name: imr access type: read-only offset: 0x1c reset value: 0x00000000 0: the corresponding interrupt is disabled. 1: the corresponding interrupt is enabled. a bit in this register is cleared when the corresponding bit in idr is written to one. a bit in this register is set when the corresponding bit in ier is written to one. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------- 76543210 - txur txrdy - - rxor rxrdy -
796 42023e?sam?07/2013 atsam4l8/l4/l2 29.8.9 receive holding register name: rhr access type: read-only offset: 0x20 reset value: 0x00000000 ? rhr: received word this field is set by hardware to the last received data word. if mr.datalength specifies less than 32 bits, data shall be right - justified into the rhr field. 31 30 29 28 27 26 25 24 rhr[31:24] 23 22 21 20 19 18 17 16 rhr[23:16] 15 14 13 12 11 10 9 8 rhr[15:8] 76543210 rhr[7:0]
797 42023e?sam?07/2013 atsam4l8/l4/l2 29.8.10 transmit holding register name: thr access type: write-only offset: 0x24 reset value: 0x00000000 ? thr: data word to be transmitted next data word to be transmitted after the current word if txrd y is not set. if mr.datalength s pecifies less than 32 bits, data shall be right-justified into the thr field. 31 30 29 28 27 26 25 24 thr[31:24] 23 22 21 20 19 18 17 16 thr[23:16] 15 14 13 12 11 10 9 8 thr[15:8] 76543210 thr[7:0]
798 42023e?sam?07/2013 atsam4l8/l4/l2 29.8.11 module version name: version access type: read-only offset: 0x28 reset value: - ? variant: variant number reserved. no functionality associated. ? version: version number version number of the module. no functionality associated. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 ---- variant 15 14 13 12 11 10 9 8 ---- version[11:8] 76543210 version[7:0]
799 42023e?sam?07/2013 atsam4l8/l4/l2 29.8.12 module parameters name: parameter access type: read-only offset: 0x2c reset value: - reserved. no functionality associated. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------- 76543210 --------
800 42023e?sam?07/2013 atsam4l8/l4/l2 29.9 module configuration the specific configuration for each iisc instance is listed in the followin g tables. the module bus clocks listed here are connected to the system bus clocks. refer to section 10. ?power manager (pm)? on page 108 for details. table 29-7. iisc clocks clock name description clk_iisc clock for the iisc bus interface gclk the generic clock used for the iisc is gclk6 table 29-8. register reset values register reset value version 0x00000100
801 42023e?sam?07/2013 atsam4l8/l4/l2 30. timer/counter (tc) rev: 4.0.2.0 30.1 features ? three 16-bit timer counter channels ? a wide range of functions including: ? frequency measurement ? event counting ? interval measurement ? pulse generation ?delay timing ? pulse width modulation ? up/down capabilities ? 2-bit gray up/down count for stepper motor ? each channel is user-conf igurable and contains: ? three external clock inputs ? five internal clock inputs ? two multi-purpose input/output signals ? internal interrupt signal ? two global registers that act on all three tc channels ? configuration registers can be write protected ? peripheral event input on al l a/b lines in capture mode 30.2 overview the timer counter (tc) includes three identical 16-bit timer counter channels. each channel can be independently programmed to perform a wide range of functions including frequency measurement, event counting, interval measurement, pulse generation, delay timing, and pulse width modulation. each channel has three external clock inputs, fi ve internal clock inputs, and two multi-purpose input/output signals which can be configured by the user. each channel drives an internal inter- rupt signal which can be programmed to generate processor interrupts. the tc block has two global registers which act upon all three tc channels. the block control register (bcr) allows the th ree channels to be started simultaneously with the same instruction. the block mode register (bmr) defines the ex ternal clock inputs for each channel, allowing them to be chained.
802 42023e?sam?07/2013 atsam4l8/l4/l2 30.3 block diagram 30.4 i/o lines description 30.5 product dependencies in order to use this module, other parts of the system must be configured correctly, as described below. 30.5.1 i/o lines the pins used for interfacing the compliant external devices may be multiplexed with i/o lines. the user must first program the i/o controller to assign the tc pins to their peripheral functions. i/o co n t r o l l e r tc2xc2s int0 int1 int2 tioa0 tioa1 tioa2 tiob0 tiob1 tiob2 xc2 tclk0 tclk1 tclk2 tclk0 tclk1 tclk2 tclk0 tclk1 tclk2 tioa1 tioa2 tioa0 tioa2 tioa1 interrupt controller clk0 clk1 clk2 a0 b0 a1 b1 a2 b2 timer count er tiob tioa tiob sync timer_clock1 tioa sync sync tioa tiob timer_clock2 timer_clock3 timer_clock4 timer_clock5 xc1 xc0 xc0 xc2 xc1 xc0 xc1 xc2 timer/counter channel 2 timer/counter channel 1 timer/counter channel 0 tc1xc1s tc0xc0s tioa0 table 30-1. i/o lines description pin name description type clk0-clk2 external clock input input a0-a2 i/o line a input/output b0-b2 i/o line b input/output
803 42023e?sam?07/2013 atsam4l8/l4/l2 when using the tioa/tiob lines as inputs the us er must make sure that no peripheral events are generated on the line. refer to section 31. ?peripheral event controller (pevc)? on page 844 for details. 30.5.2 power management if the cpu enters a sleep mode that disables cl ocks used by the tc, the tc will stop functioning and resume operation after the system wakes up from sleep mode. 30.5.3 clocks the clock for the tc bus interface (clk_tc) is generated by the power manager. this clock is disabled at reset, and can be enabled in the power manager. it is recommended to disable the tc before disabling the clock, to avoid freezing the tc in an undefined state. 30.5.4 interrupts the tc interrupt request line is connected to the nvic. using the tc interrupt requires the nvic to be programmed first. 30.5.5 peripheral events the tc peripheral events are connected via the peripheral event system. refer to section 31. ?peripheral event contro ller (pevc)? on page 844 for details. 30.5.6 debug operation the timer counter clocks are frozen du ring debug operation, unless the ocd system keeps peripherals running in debug operation. 30.6 functional description 30.6.1 tc description the three channels of the timer counter are independent and identical in operation. the regis- ters for channel programming are listed in figure 30-3 on page 818 . 30.6.1.1 channel i/o signals as described in figure 30.3 on page 802 , each channel has the following i/o signals. 30.6.1.2 16-bit counter each channel is organized around a 16-bit counter. the value of the counter is incremented at each positive edge of the selected clock. when the counter has reached the value 0xffff and table 30-2. channel i/o signals description block/channel sign al name description channel signal xc0, xc1, xc2 external clock inputs tioa capture mode: timer counter input waveform mode: timer counter output tiob capture mode: timer counter input waveform mode: timer counter input/output int interrupt signal output sync synchronization input signal
804 42023e?sam?07/2013 atsam4l8/l4/l2 passes to 0x0000, an overflow occurs and the counter overflow status bit in the channel n sta- tus register (srn.covfs) is set. the current value of the counter is accessible in real time by reading the channel n counter value register (cvn). the counter can be reset by a trigger. in this case, the counter value passes to 0x0000 on the next valid edge of the selected clock. 30.6.1.3 clock selection at block level, input clock signals of each channel can either be connected to the external inputs tclk0, tclk1 or tclk2, or be connected to the configurable i/o signals a0, a1 or a2 for chaining by writing to the bmr register. see figure 30-1 on page 805 . each channel can independently select an internal or external clock source for its counter: ? internal clock signals: timer_cl ock1, timer_clock2, timer_clock3, timer_clock4, timer_clock5. see the module configuration chapter for details about the connection of these clock sources. ? external clock signals: xc0, xc1 or xc2. see the module configuration chapter for details about the connection of these clock sources. this selection is made by the clock sele ction field in the channel n mode register (cmrn.tcclks). the selected clock can be inverted with the clock invert bit in cmrn (cmrn.clki). this allows counting on the opposite edges of the clock. the burst function allows the clock to be valida ted when an external signal is high. the burst signal selection field in the cmrn regi ster (cmrn.burst) defines this signal. note: in all cases, if an external clock is used, the du ration of each of its leve ls must be longer than the clk_tc period. the external clock frequency must be at least 2.5 times lower than the clk_tc.
805 42023e?sam?07/2013 atsam4l8/l4/l2 figure 30-1. clock selection 30.6.1.4 clock control the clock of each counter can be controlled in two different ways: it can be enabled/disabled and started/stopped. see figure 30-2 on page 806 . ? the clock can be enabled or disabled by the user by writing to the counter clock enable/disable command bits in the channel n clock contro l register (ccrn.clken and ccrn.clkdis). in capture mode it can be disabled by an rb load event if the counter clock disable with rb loading bit in cmrn is written to one (cmrn.ldbdis). in waveform mode, it can be disabled by an rc compare event if the counter clock disable with rc compare bit in cmrn is written to one (cmrn.cpcdis). when disabled, the start or the stop actions have no effect: only a clken command in ccrn can re-enable the clock. when the clock is enabled, the clock enabling status bit is set in srn (srn.clksta). ? the clock can also be started or stopped: a trigger (software, synchro, external or compare) always starts the clock. in capture mode the clock can be stopped by an rb load event if the counter clock stopped with rb loading bit in cmrn is written to one (cmrn.ldbstop). in waveform mode it can be stopped by an rc compare event if the counter clock stopped with rc compare bit in cmrn is written to one (cmrn.cpcstop). the start and the stop commands have effect only if the clock is enabled. timer_clock5 xc2 tcclks clki burst 1 selected clock xc1 xc0 timer_clock4 timer_clock3 timer_clock2 timer_clock1
806 42023e?sam?07/2013 atsam4l8/l4/l2 figure 30-2. clock control 30.6.1.5 tc operating modes each channel can independently operate in two different modes: ? capture mode provides measurement on signals. ? waveform mode provides wave generation. the tc operating mode selection is done by writing to the wave bit in the ccrn register (ccrn.wave). in capture mode, tioa and tiob are configured as inputs. in waveform mode, tioa is always configured to be an output and tiob is an output if it is not selected to be the external trigger. 30.6.1.6 trigger a trigger resets the counter and starts the counter clock. three types of triggers are common to both modes, and a fourth external trigger is available to each mode. the following triggers are common to both modes: ? software trigger: each channel has a software trigger, available by writing a one to the software trigger command bi t in ccrn (ccrn.swtrg). ? sync: each channel has a synchronization signal sync. when asserted, this signal has the same effect as a software trigger. the sync signals of all channels are asserted simultaneously by writing a one to the synchro command bit in the bcr register (bcr.sync). ? compare rc trigger: rc is implemented in each channel and can provide a trigger when the counter value matches the rc value if the rc compare trigger enable bit in cmrn (cmrn.cpctrg) is written to one. qs r s r q clksta clken clkdis stop event disable counter clock selected clock trigger event
807 42023e?sam?07/2013 atsam4l8/l4/l2 the channel can also be configured to have an external trigger. in capture mode, the external trigger signal can be selected between tioa and tiob. in waveform mode, an external event can be programmed to be one of the following si gnals: tiob, xc0, xc1, or xc2. this external event can then be programmed to perform a trigger by writing a one to the external event trig- ger enable bit in cmrn (cmrn.enetrg). if an external trigger is used, the duration of the pulses must be longer than the clk_tc period in order to be detected. regardless of the trigger used, it will be taken into account at the following active edge of the selected clock. this means that the counter value can be read differently from zero just after a trigger, especially when a low frequency signal is selected as the clock. 30.6.1.7 peripheral events on tioa/tiob inputs the tioa /tiob input lines are ored internally with peripheral events from the peripheral event system. to capture using events the user must ensure that the corresp onding pin functions for the tioa /tiob line are disabled. when capturing on the external tioa /tiob pin the user must ensure that no peripheral events are generated on this pin. 30.6.2 capture operating mode this mode is entered by writin g a zero to the cmrn.wave bit. capture mode allows the tc channel to perform measurements such as pulse timing, fre- quency, period, duty cycle and phase on tioa and tiob sig nals which are considered as inputs. figure 30-3 on page 808 shows the configuration of the tc channel when programmed in cap- ture mode. 30.6.2.1 capture registers a and b registers a and b (ra and rb) are used as capture registers. this means that they can be loaded with the counter value when a progr ammable event occurs on the signal tioa. the ra loading selection field in cmrn (cmrn.ldra) defines the tioa edge for the loading of the ra register, and the rb loading selection fi eld in cmrn (cmrn.ldrb) defines the tioa edge for the loading of the rb register. ra is loaded only if it has not been loaded since the last trigger or if rb has been loaded since the last loading of ra. rb is loaded only if ra has been loaded sinc e the last trigger or t he last loading of rb. loading ra or rb before the read of the last value loaded sets the load overrun status bit in srn (srn.lovrs). in this case, the old value is overwritten. 30.6.2.2 trigger conditions in addition to the sync signal, the software trigger and the rc compare trigger, an external trig- ger can be defined. the tioa or tiob external trigger selection bit in cmrn (cmrn.abetrg) selects tioa or tiob input signal as an external trigger. the external trigger edge selection bit in cmrn (cmrn.etredg) defines the edge (rising, falling or both) detected to generate an external trig- ger. if cmrn.etrgedg is zero (none), the external trigger is disabled.
808 42023e?sam?07/2013 atsam4l8/l4/l2 figure 30-3. capture mode timer_clock1 xc 0 xc 1 xc 2 tcclks clki qs r s r q clksta clken clkdis burst tiob capture register a compare rc = 16-bit counter abetrg swtrg etrgedg cpctrg imr trig ldrbs ldras etrgs sr lovrs covfs sync 1 mtiob tioa mtioa ldra ldbstop if ra is not loaded or rb is loaded if ra is loaded ldbdis cpcs int ed g e det ect or ldrb clk ovf reset timer/counter channel edge detector edge detector capture register b register c timer_clock2 timer_clock3 timer_clock4 timer_clock5
809 42023e?sam?07/2013 atsam4l8/l4/l2 30.6.3 waveform operating mode waveform operating mode is entered by writing a one to the cmrn.wave bit. in waveform operating mode the tc channel generates one or two pwm signals with the same frequency and independently programmable duty cy cles, or generates different types of one- shot or repetitive pulses. in this mode, tioa is configured as an output and tiob is defined as an output if it is not used as an external event. figure 30-4 on page 810 shows the configuration of the tc channel when programmed in waveform operating mode. 30.6.3.1 waveform selection depending on the waveform se lection field in cmrn (cmrn. wavsel), the behavior of cvn varies. with any selection, ra, rb and rc can all be used as compare registers. ra compare is used to control the tioa output, rb compare is used to control the tiob output (if correctly configured) and rc compare is used to control tioa and/or tiob outputs.
810 42023e?sam?07/2013 atsam4l8/l4/l2 figure 30-4. waveform mode tcclks clki qs r s r q clksta clken clkdis cpcdis burst tiob register a compare rc = cpcstop 16-bit counter eevt eev t e d g sync swtrg en etr g wavsel imr tr i g acpc acpa aeevt aswtrg bcpc bcpb beevt bswtrg tioa mtioa tiob mtiob cpas covfs etrgs sr cpcs cpbs clk ovf reset output contr oller output controller int 1 edge det ect o r timer/counter channel timer_clock1 xc 0 xc 1 xc 2 wavsel register b register c compare rb = compare ra = timer_clock2 timer_clock3 timer_clock4 timer_clock5
811 42023e?sam?07/2013 atsam4l8/l4/l2 30.6.3.2 wavsel = 0 when cmrn.wavsel is zero, the value of cv n is incremented fr om 0 to 0xffff. once 0xffff has been reached, the value of cvn is re set. incrementation of cvn starts again and the cycle continues. see figure 30-5 on page 811 . an external event trigger or a software trigger can reset the value of cvn. it is important to note that the trigger may occur at any time. see figure 30-6 on page 812 . rc compare cannot be programmed to generate a trigger in this configuration. at the same time, rc compare can stop the counter clock (cmrn.cpcstop = 1) and/or disable the counter clock (cmrn.cpcdis = 1). figure 30-5. wavsel= 0 without trigger time counter value rc rb ra tiob tioa counter cleared by compare match with 0xffff 0xffff waveform examples
812 42023e?sam?07/2013 atsam4l8/l4/l2 figure 30-6. wavsel= 0 with trigger 30.6.3.3 wavsel = 2 when cmrn.wavsel is two, the value of cvn is incremented from zero to the value of rc, then automatically reset on a rc compare. once the value of cvn has been reset, it is then incremented and so on. see figure 30-7 on page 813 . it is important to note that cvn can be reset at any time by an external event or a software trig- ger if both are programmed correctly. see figure 30-8 on page 813 . in addition, rc compare can stop the counter clock (cmrn.cpcstop) and/or disable the counter clock (cmrn.cpcdis = 1). time counter value rc rb ra tiob tioa counter cleared by compare match with 0xffff 0xffff waveform examples counter cleared by trigger
813 42023e?sam?07/2013 atsam4l8/l4/l2 figure 30-7. wavsel = 2 without trigger figure 30-8. wavsel = 2 with trigger 30.6.3.4 wavsel = 1 when cmrn.wavsel is one, the value of cvn is incremented from 0 to 0xffff. once 0xffff is reached, the value of cvn is decremented to 0, then re-incremented to 0xffff and so on. see figure 30-9 on page 814 . time counter value rc rb ra tiob tioa counter cleared by compare match with rc 0xffff waveform examples time counter value r c r b r a tiob tioa counter cleared by compare match with rc 0xffff waveform examples counter cleared by trigger
814 42023e?sam?07/2013 atsam4l8/l4/l2 a trigger such as an external event or a software trigger can modify cvn at any time. if a trigger occurs while cvn is incrementing, cvn then decrements. if a trigger is received while cvn is decrementing, cvn then increments. see figure 30-10 on page 814 . rc compare cannot be programmed to generate a trigger in this configuration. at the same time, rc compare can stop the counter clock (cmrn.cpcstop = 1) and/or dis- able the counter clock (cmrn.cpcdis = 1). figure 30-9. wavsel = 1 without trigger figure 30-10. wavsel = 1 with trigger time counter value rc rb ra tiob tioa counter decremented by compare match with 0xffff 0xffff waveform examples time counter value tiob tioa counter decremented by compare match with 0xffff 0xffff waveform examples counter decremented by trigger rc rb ra counter incremented by trigger
815 42023e?sam?07/2013 atsam4l8/l4/l2 30.6.3.5 wavsel = 3 when cmrn.wavsel is three, the value of cvn is incremented from ze ro to rc. once rc is reached, the value of cvn is decremented to zero, then re-incremented to rc and so on. see figure 30-11 on page 815 . a trigger such as an external event or a software trigger can modify cvn at any time. if a trigger occurs while cvn is incrementing, cvn then decrements. if a trigger is received while cvn is decrementing, cvn then increments. see figure 30-12 on page 816 . rc compare can stop the counter clock (cmrn.cp cstop = 1) and/or disable the counter clock (cmrn.cpcdis = 1). figure 30-11. wavsel = 3 without trigger time counter value rc rb ra tiob tioa counter cleared by compare match with rc 0xffff waveform examples
816 42023e?sam?07/2013 atsam4l8/l4/l2 figure 30-12. wavsel = 3 with trigger 30.6.3.6 external event/trigger conditions an external event can be programmed to be detected on one of the clock sources (xc0, xc1, xc2) or tiob. the external event selected can then be used as a trigger. the external event selection field in cmrn (cmrn.eevt) selects the external trigger. the external event edge selection field in cmrn (cmrn.eevtedg) defines the trigger edge for each of the possible external triggers (rising, fa lling or both). if cmrn.eevtedg is written to zero, no external event is defined. if tiob is defined as an ex ternal event signal (cmrn.eevt = 0), tiob is no longer used as an output and the compare register b is not used to generate waveforms and subsequently no irqs. in this case the tc channel can only generate a waveform on tioa. when an external event is defined, it can be used as a trigger by writing a one to the cmrn.enetrg bit. as in capture mode, the sync signal and the softw are trigger are also available as triggers. rc compare can also be used as a trigger depending on the cmrn.wavsel field. 30.6.3.7 output controller the output controller defines the output level changes on tioa and tiob following an event. tiob control is used only if tiob is defin ed as output (not as an external event). the following events control tioa and tiob: ? software trigger ? external event ? rc compare ra compare controls tioa and rb compare controls tiob. each of these events can be pro- grammed to set, clear or toggle the output as defined in the following fields in cmrn: ? rc compare effect on tiob (cmrn.bcpc) time counter value tiob tioa counter decremented by compare match with rc 0xffff waveform examples rc rb ra counter decremented by trigger counter incremented by trigger
817 42023e?sam?07/2013 atsam4l8/l4/l2 ? rb compare effect on tiob (cmrn.bcpb) ? rc compare effect on tioa (cmrn.acpc) ? ra compare effect on tioa (cmrn.acpa) 30.7 2-bit gray up/down counter for stepper motor each channel can be independently configured to generate a 2-bit gray count waveform on cor- responding tioa, tiob outputs by means of gcen bit in smmrx registers. up or down count can be defined by writing bit down in smmrx registers. it is mandatory to conf igure the channel in wave mode in cmr register. the period of the counters can be programmed on rcx registers. figure 30-13. 2-bit gray up/down counter. 30.8 write protection system in order to bring security to the timer counter, a write protection system has been implemented. the write protection mode prevent the write of bmr, fmr, cmrx, smmrx, rax, rbx, rcx reg- isters. when this mode is enabled and one of the prot ected registers write, the register write request canceled. due to the nature of the write protection feature, enabling and disabling the write protection mode requires the use of a security code. thus when enabling or disabling the write protection mode the wpkey field of the wpmr register mu st be filled with the ?tim? ascii code (corre- sponding to 0x54494d) otherwise th e register write will be canceled.
818 42023e?sam?07/2013 atsam4l8/l4/l2 30.9 user interface table 30-3. tc register memory map offset register register name access reset 0x00 channel 0 control register ccr0 write-only 0x00000000 0x04 channel 0 mode register cmr0 read/write 0x00000000 0x08 ch 0 stepper motor mode register smmr0 read/write 0x00000000 0x10 channel 0 counter value cv0 read-only 0x00000000 0x14 channel 0 register a ra0 read/write (1) 0x00000000 0x18 channel 0 register b rb0 read/write (1) 0x00000000 0x1c channel 0 register c rc0 read/write 0x00000000 0x20 channel 0 status register sr0 read-only 0x00000000 0x24 interrupt enable register ier0 write-only 0x00000000 0x28 channel 0 interrupt disable register idr0 write-only 0x00000000 0x2c channel 0 interrupt mask register imr0 read-only 0x00000000 0x40 channel 1 control register ccr1 write-only 0x00000000 0x44 channel 1 mode register cmr1 read/write 0x00000000 0x48 ch 1 stepper motor mode register smmr1 read/write 0x00000000 0x50 channel 1 counter value cv1 read-only 0x00000000 0x54 channel 1 register a ra1 read/write (1) 0x00000000 0x58 channel 1 register b rb1 read/write (1) 0x00000000 0x5c channel 1 register c rc1 read/write 0x00000000 0x60 channel 1 status register sr1 read-only 0x00000000 0x64 channel 1 interrupt enable register ier1 write-only 0x00000000 0x68 channel 1 interrupt disable register idr1 write-only 0x00000000 0x6c channel 1 interrupt mask register imr1 read-only 0x00000000 0x80 channel 2 control register ccr2 write-only 0x00000000 0x84 channel 2 mode register cmr2 read/write 0x00000000 0x88 ch 2 stepper motor mode register smmr2 read/write 0x00000000 0x90 channel 2 counter value cv2 read-only 0x00000000 0x94 channel 2 register a ra2 read/write (1) 0x00000000 0x98 channel 2 register b rb2 read/write (1) 0x00000000 0x9c channel 2 register c rc2 read/write 0x00000000 0xa0 channel 2 status register sr2 read-only 0x00000000 0xa4 channel 2 interrupt enable register ier2 write-only 0x00000000 0xa8 channel 2 interrupt disable register idr2 write-only 0x00000000 0xac channel 2 interrupt mask register imr2 read-only 0x00000000 0xc0 block control register bcr write-only 0x00000000 0xc4 block mode register bmr read/write 0x00000000
819 42023e?sam?07/2013 atsam4l8/l4/l2 notes: 1. read-only if cmrn.wave is zero. 2. the reset values are device specific. refer to the module configuration section at the end of this chapter. 0xe4 write protect mode register wpmr read/write 0x00000000 0xf8 features register features read-only - (2) 0xfc version register version read-only - (2) table 30-3. tc register memory map offset register register name access reset
820 42023e?sam?07/2013 atsam4l8/l4/l2 30.9.1 channel control register name: ccr access type: write-only offset: 0x00 + n * 0x40 reset value: 0x00000000 ? swtrg: software trigger command 1: writing a one to this bit will perform a software tr igger: the counter is reset and the clock is started. 0: writing a zero to this bit has no effect. ? clkdis: counter cl ock disable command 1: writing a one to this bit will disable the clock. 0: writing a zero to this bit has no effect. ? clken: counter clock enable command 1: writing a one to this bit will enab le the clock if clkdis is not one. 0: writing a zero to this bit has no effect. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 ---- ---- 15 14 13 12 11 10 9 8 -------- 76543210 - - - - - swtrg clkdis clken
821 42023e?sam?07/2013 atsam4l8/l4/l2 30.9.2 channel mode register: capture mode name: cmr access type: read/write offset: 0x04 + n * 0x40 reset value: 0x00000000 this register can only be written if writ e protect is disabled (wpmr.wpen is zero). ? ldrb: rb loading selection ? ldra: ra loading selection ?wave 1: capture mode is disabled (waveform mode is enabled). 0: capture mode is enabled. ? cpctrg: rc compare trigger enable 1: rc compare resets the counter and starts the counter clock. 0: rc compare has no effect on the counter and its clock. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 - - - - ldrb ldra 15 14 13 12 11 10 9 8 wave cpctrg - - - abetrg etrgedg 76543210 ldbdis ldbstop burst clki tcclks ldrb edge 0 none 1 rising edge of tioa 2 falling edge of tioa 3 each edge of tioa ldra edge 0 none 1 rising edge of tioa 2 falling edge of tioa 3 each edge of tioa
822 42023e?sam?07/2013 atsam4l8/l4/l2 ? abetrg: tioa or tiob external trigger selection 1: tioa is used as an external trigger. 0: tiob is used as an external trigger. ? etrgedg: external trigger edge selection ? ldbdis: counter clock disable with rb loading 1: counter clock is disabled when rb loading occurs. 0: counter clock is not disabled when rb loading occurs. ? ldbstop: counter clock stopped with rb loading 1: counter clock is stopped when rb loading occurs. 0: counter clock is not stopped when rb loading occurs. ? burst: burst signal selection ? clki: clock invert 1: the counter is incremented on falling edge of the clock. 0: the counter is incremented on rising edge of the clock. ? tcclks: clock selection etrgedg edge 0 none 1 rising edge 2 falling edge 3 each edge burst burst signal selection 0 the clock is not gated by an external signal 1 xc0 is anded with the selected clock 2 xc1 is anded with the selected clock 3 xc2 is anded with the selected clock tcclks clock selected 0timer_clock1 1timer_clock2 2timer_clock3 3timer_clock4 4timer_clock5 5xc0 6xc1 7xc2
823 42023e?sam?07/2013 atsam4l8/l4/l2 30.9.3 channel mode re gister: waveform mode name: cmr access type: read/write offset: 0x04 + n * 0x40 reset value: 0x00000000 this register can only be written if writ e protect is disabled (wpmr.wpen is zero). ? bswtrg: software trigger effect on tiob ? beevt: external event effect on tiob 31 30 29 28 27 26 25 24 bswtrg beevt bcpc bcpb 23 22 21 20 19 18 17 16 aswtrg aeevt acpc acpa 15 14 13 12 11 10 9 8 wave wavsel enetrg eevt eevtedg 76543210 cpcdis cpcstop burst clki tcclks bswtrg effect 0 none 1set 2clear 3 toggle beevt effect 0 none 1set 2clear 3 toggle
824 42023e?sam?07/2013 atsam4l8/l4/l2 ? bcpc: rc compare effect on tiob ? bcpb: rb compare effect on tiob ? aswtrg: software trigger effect on tioa ? aeevt: external event effect on tioa ? acpc: rc compare effect on tioa bcpc effect 0 none 1set 2clear 3 toggle bcpb effect 0 none 1set 2clear 3 toggle aswtrg effect 0 none 1set 2clear 3 toggle aeevt effect 0 none 1set 2clear 3 toggle acpc effect 0 none 1set 2clear 3 toggle
825 42023e?sam?07/2013 atsam4l8/l4/l2 ? acpa: ra compare effect on tioa ?wave 1: waveform mode is enabled. 0: waveform mode is disabled (capture mode is enabled). ? wavsel: waveform selection ? enetrg: external event trigger enable 1: the external event resets the counter and starts the counter clock. 0: the external event has no effect on the counter and its clock. in this case, the selected external event only controls the t ioa output. ? eevt: external event selection note: 1. if tiob is chosen as the external event signal, it is conf igured as an input and no longer generates waveforms and subse- quently no irqs . ? eevtedg: external ev ent edge selection ? cpcdis: counter clock disable with rc compare 1: counter clock is disabled when counter reaches rc. 0: counter clock is not disabled when counter reaches rc. acpa effect 0 none 1set 2clear 3 toggle wavsel effect 0 up mode without automatic trigger on rc compare 1 updown mode without automat ic trigger on rc compare 2 up mode with automatic trigger on rc compare 3 updown mode with automatic trigger on rc compare eevt signal selected as exte rnal event tiob direction 0 tiob input (1) 1 xc0 output 2 xc1 output 3 xc2 output eevtedg edge 0none 1 rising edge 2 falling edge 3 each edge
826 42023e?sam?07/2013 atsam4l8/l4/l2 ? cpcstop: counter clock stopped with rc compare 1: counter clock is stopped when counter reaches rc. 0: counter clock is not stopped when counter reaches rc. ? burst: burst signal selection ? clki: clock invert 1: counter is incremented on falling edge of the clock. 0: counter is incremented on rising edge of the clock. ? tcclks: clock selection burst burst signal selection 0 the clock is not gated by an external signal. 1 xc0 is anded with the selected clock. 2 xc1 is anded with the selected clock. 3 xc2 is anded with the selected clock. tcclks clock selected 0timer_clock1 1timer_clock2 2timer_clock3 3timer_clock4 4timer_clock5 5xc0 6xc1 7xc2
827 42023e?sam?07/2013 atsam4l8/l4/l2 30.9.4 stepper motor mode register name: smcr access type: read/write offset: 0x08 + n * 0x40 reset value: 0x00000000 this register can only be written if writ e protect is disabled (wpmr.wpen is zero). ? down: down count 0: up counter. 1: down counter. ? gcen: gray count enable 0: tioax and tiobx are driven by internal counter of channel x. 1: tioax and tiobx are driven by a 2-bit gray counter. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 ---- ---- 15 14 13 12 11 10 9 8 -------- 76543210 ------downgcen
828 42023e?sam?07/2013 atsam4l8/l4/l2 30.9.5 channel counter value register name: cv access type: read-only offset: 0x10 + n * 0x40 reset value: 0x00000000 ?cv: counter value cv contains the counter value in real time. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 ---- ---- 15 14 13 12 11 10 9 8 cv[15:8] 76543210 cv[7:0]
829 42023e?sam?07/2013 atsam4l8/l4/l2 30.9.6 channel register a name: ra access type: read-only if cmrn.wave = 0, read/write if cmrn.wave = 1 offset: 0x14 + n * 0x40 reset value: 0x00000000 this register can only be written if writ e protect is disabled (wpmr.wpen is zero). ? ra: register a ra contains the register a value in real time. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 ---- ---- 15 14 13 12 11 10 9 8 ra[15:8] 76543210 ra[7:0]
830 42023e?sam?07/2013 atsam4l8/l4/l2 30.9.7 channel register b name: rb access type: read-only if cmrn.wave = 0, read/write if cmrn.wave = 1 offset: 0x18 + n * 0x40 reset value: 0x00000000 this register can only be written if writ e protect is disabled (wpmr.wpen is zero). ? rb: register b rb contains the register b value in real time. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 ---- ---- 15 14 13 12 11 10 9 8 rb[15:8] 76543210 rb[7:0]
831 42023e?sam?07/2013 atsam4l8/l4/l2 30.9.8 channel register c name: rc access type: read/write offset: 0x1c + n * 0x40 reset value: 0x00000000 this register can only be written if writ e protect is disabled (wpmr.wpen is zero). ? rc: register c rc contains the register c value in real time. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 ---- ---- 15 14 13 12 11 10 9 8 rc[15:8] 76543210 rc[7:0]
832 42023e?sam?07/2013 atsam4l8/l4/l2 30.9.9 channel status register name: sr access type: read-only offset: 0x20 + n * 0x40 reset value: 0x00000000 note: reading the status register will also clear th e interrupt bit for the co rresponding interrupts. ? mtiob: tiob mirror 1: tiob is high. if cmrn.wave is zero, this means that tiob pi n is high. if cmrn.wave is one, this means that tiob is driven high. 0: tiob is low. if cmrn.wave is zero, this means that tiob pi n is low. if cmrn.wave is one, this means that tiob is driven low. ? mtioa: tioa mirror 1: tioa is high. if cmrn.wave is zero, this means that tioa pin is high. if cmrn.wave is one, th is means that tioa is driven high. 0: tioa is low. if cmrn.wave is zero, this means that tioa pin is low. if cmrn.wave is one, this means that tioa is driven low. ? clksta: clock enabling status 1: this bit is set when the clock is enabled. 0: this bit is cleared when the clock is disabled. ? etrgs: external trigger status 1: this bit is set when an external trigger has occurred. 0: this bit is cleared when the sr register is read. ? ldrbs: rb loading status 1: this bit is set when an rb load has occurred and cmrn.wave is zero. 0: this bit is cleared when the sr register is read. ? ldras: ra loading status 1: this bit is set when an ra load has occurred and cmrn.wave is zero. 0: this bit is cleared when the sr register is read. ? cpcs: rc compare status 1: this bit is set when an rc compare has occurred. 0: this bit is cleared when the sr register is read. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 ---- - mtiob mtioa clksta 15 14 13 12 11 10 9 8 -------- 76543210 etrgs ldrbs ldras cpcs cpbs cpas lovrs covfs
833 42023e?sam?07/2013 atsam4l8/l4/l2 ? cpbs: rb compare status 1: this bit is set when an rb compare has occurred and cmrn.wave is one. 0: this bit is cleared when the sr register is read. ? cpas: ra compare status 1: this bit is set when an ra compare has occurred and cmrn.wave is one. 0: this bit is cleared when the sr register is read. ? lovrs: load overrun status 1: this bit is set when ra or rb have been loaded at l east twice without any read of the corresponding register and cmrn.wave is zero. 0: this bit is cleared when the sr register is read. ? covfs: counter overflow status 1: this bit is set when a counter overflow has occurred. 0: this bit is cleared when the sr register is read.
834 42023e?sam?07/2013 atsam4l8/l4/l2 30.9.10 channel interrupt enable register name: ier access type: write-only offset: 0x24 + n * 0x40 reset value: 0x00000000 writing a zero to a bit in this register has no effect. writing a one to a bit in this register will set the corresponding bit in imr. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 ---- ---- 15 14 13 12 11 10 9 8 -------- 76543210 etrgs ldrbs ldras cpcs cpbs cpas lovrs covfs
835 42023e?sam?07/2013 atsam4l8/l4/l2 30.9.11 channel interrupt disable register name: idr access type: write-only offset: 0x28 + n * 0x40 reset value: 0x00000000 writing a zero to a bit in this register has no effect. writing a one to a bit in this register will clear the corresponding bit in imr. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 ---- ---- 15 14 13 12 11 10 9 8 -------- 76543210 etrgs ldrbs ldras cpcs cpbs cpas lovrs covfs
836 42023e?sam?07/2013 atsam4l8/l4/l2 30.9.12 channel interrupt mask register name: imr access type: read-only offset: 0x2c + n * 0x40 reset value: 0x00000000 0: the corresponding interrupt is disabled. 1: the corresponding interrupt is enabled. a bit in this register is cleared when the corresponding bit in idr is written to one. a bit in this register is set when the corresponding bit in ier is written to one. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 ---- ---- 15 14 13 12 11 10 9 8 -------- 76543210 etrgs ldrbs ldras cpcs cpbs cpas lovrs covfs
837 42023e?sam?07/2013 atsam4l8/l4/l2 30.9.13 block control register name: bcr access type: write-only offset: 0xc0 reset value: 0x00000000 ? sync: synchro command 1: writing a one to this bit asserts the sync signal which generates a software trigger simultaneously for each of the channels . 0: writing a zero to this bit has no effect. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 ---- ---- 15 14 13 12 11 10 9 8 -------- 76543210 -------sync
838 42023e?sam?07/2013 atsam4l8/l4/l2 30.9.14 block mode register name: bmr access type: read/write offset: 0xc4 reset value: 0x00000000 this register can only be written if writ e protect is disabled (wpmr.wpen is zero). 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 ---- ---- 15 14 13 12 11 10 9 8 -------- 76543210 - - tc2xc2s tc1xc1s tc0xc0s
839 42023e?sam?07/2013 atsam4l8/l4/l2 ? tc2xc2s: external clock signal 2 selection ? tc1xc1s: external clock signal 1 selection ? tc0xc0s: external cloc k signal 0 selection tc2xc2s signal connected to xc2 0tclk2 1none 2tioa0 3tioa1 tc1xc1s signal connected to xc1 0tclk1 1none 2tioa0 3tioa2 tc0xc0s signal connected to xc0 0tclk0 1none 2tioa1 3tioa2
840 42023e?sam?07/2013 atsam4l8/l4/l2 30.9.15 write protect mode register name: wpmr access type: read/write offset: 0xe4 reset value: 0x00000000 ? wpkey: write protect key valid key is ?tim? in ascii (0x54494d in hexadecimal). ? wpen: write protect enable 1: writing a one to this bit will enable write protection (wpkey must be set). 0: writing a zero to this bit will disa ble write protection (wpkey must be set). protected registers: channel mode register: capture mode channel mode register: waveform mode stepper motor mode register register a register b register c block mode register 31 30 29 28 27 26 25 24 wpkey 23 22 21 20 19 18 17 16 wpkey 15 14 13 12 11 10 9 8 wpkey 76543210 -------wpen
841 42023e?sam?07/2013 atsam4l8/l4/l2 30.9.16 features register name: features access type: read-only offset: 0xf8 reset value: - ? brpbhsb: bridge type is pb to hsb 1: bridge type is pb to hsb. 0: bridge type is not pb to hsb. ? updnimpl: up/down is implemented 1: up/down counter capability is implemented. 0: up/down counter capability is not implemented. ? ctrsize: counter size this field indicates the size of the counter in bits. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 ---- --- 15 14 13 12 11 10 9 8 - - - - - - brpbhsb updnimpl 76543210 ctrsize
842 42023e?sam?07/2013 atsam4l8/l4/l2 30.9.17 version register name: version access type: read-only offset: 0xfc reset value: - ? variant: variant number reserved. no functionality associated. ? version: version number version number of the module. no functionality associated. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 ---- variant 15 14 13 12 11 10 9 8 - - - - version[11:8] 76543210 version[7:0]
843 42023e?sam?07/2013 atsam4l8/l4/l2 30.10 module configuration the specific configuration for each timer/counter instance is listed in the following tables.the module bus clocks listed here are connected to the system bus clocks. refer to section 10. ?power manager (pm)? on page 108 for details. each timer/counter channel can independently select an internal or external clock source for its counter: table 30-4. tc bus interface clocks module name clock name description tc0 clk_tc0 clock for the tc0 bus interface tc1 clk_tc1 clock for the tc1 bus interface table 30-5. timer/counter clock connections module source name connection tc0 internal timer_clock1 generic clock number 5 timer_clock2 pba clock / 2 timer_clock3 pba clock / 8 timer_clock4 pba clock / 32 timer_clock5 pba clock / 128 external xc0 pa14, pb13 xc1 pa15, pb14 xc2 pa16, pb15 tc1 internal timer_clock1 generic clock number 8 timer_clock2 pba clock / 2 timer_clock3 pba clock / 8 timer_clock4 pba clock / 32 timer_clock5 pba clock / 128 external xc0 pc06, pc21 xc1 pc07, pc22 xc2 pc08, pc23 table 30-6. register reset values register reset value version 0x00000402
844 42023e?sam?07/2013 atsam4l8/l4/l2 31. peripheral even t controller (pevc) rev: 2.0.0.0 31.1 features ? direct peripheral to peri pheral communication system ? allows peripherals to receive, react to, and send peripheral events without cpu intervention ? cycle deterministic event communication ? sleepwalking? and asynchronous interrupts for peripheral operation in power save modes 31.2 overview several peripheral modules can be configured to emit or respond to signals known as peripheral events. the exact condition to trigger a peripheral event, or the action taken upon receiving a peripheral event, is specific to each module. peripherals that respond to events are called users and peripherals that emit events are called generators. a module may be both a generator and user. the peripheral event generators and users are interconnected by a network known as the peripheral event system. the peripheral event controller (pevc) controls the interconnection parameters, such as generator-to-user mult iplexing and peripheral event enable/disable. the peripheral even t system allows low late ncy peripheral-to-periphe ral signalling without cpu intervention, and without cons uming system resources such as bus or ram bandwidth. this offloads the cpu and system resources compared to a traditional interrupt-based software driven system. figure 31-1. peripheral event system overview peripheral event system generator generator user generator/ user
845 42023e?sam?07/2013 atsam4l8/l4/l2 31.3 block diagram the main building blocks of the pevc are: ? channels: one channel per user, to propagate events and follow-up the user status ? event shapers (evs): instantiat ed for some generators, in ca se synchronisat ion and/or edge detection is needed prior to peripheral event propagation ? input glitch filters (igf): present specifically for i/o inputs, to filter the incoming signal prior to going through evs and channel to help distinguish the diffe rent signalling stages, following naming conventions are used: ? generators generate events ? pevc multiplexes these incoming events ? pevc outputs triggers to users figure 31-2. pevc block diagram the maximum number of generators and event shapers suppor ted by the pevc is 64. the maximum number of ch annels and users support ed by the pevc is 32. evs and igf implementation are device-specific. refer to the module configuration section at the end of this chapter for the device-specific configuration. channel 0 channel ... channel i user 0 generator ... generator 0 evs 0 pevc user ... pad_evt 0 evs ? generator ... generator j user i rcsys clk_pevc trig 0 trig... trig i evt... evt... evt j sev chmx rdy 0 rdy... rdy i clk 0 clk... clk i igf evs igf
846 42023e?sam?07/2013 atsam4l8/l4/l2 31.4 i/o lines description 31.5 product dependencies in order to use this module, other parts of the system must be configured correctly, as described below. 31.5.1 i/o lines multiplexed i/o lines can be used as event generators. to generate a peripheral event from an external source the source pin must be configured as an input pin by the i/o controller. it is also possible to trigger a peripheral event by driving these pins from registers in the i/o controller, or another peripheral output connected to the same pin. 31.5.2 power management and low power operation as the peripheral events do not require cpu intervention, they are available in idle mode. they are also available in deeper power save modes if both the generator and user remain clocked in that mode. in deeper power save modes, certain events can be issued even when the system clock is stopped, and revive unclocked us er peripherals. the clock will be restarted for this module only, without waking the system from power save mode. the clock remains active only as long as required by the triggered function, before being switched off again, and the system remains in the original sleep mode. the cpu and system will only be wo ken up if the user peripheral gener- ates an interrupt as a result of the operat ion. this concept is known as sleepwalking ? and is described in further detail in section 10. ?power manager (pm)? on page 108 . note that asyn- chronous peripheral events may be associated with a delay due to the need to restart the system clock source if this has been stopped in the sleep mode. refer to the module configuration section at the end of this chapter for the device-specific con- figuration, especially on which peripheral event generators and users can rely on sleepwalking?. the table and diagram below represent the timed behavior of sleepwalking? operations: table 31-1. i/o lines description pin name pin description type pad_evt[n] external event inputs input table 31-2. sleepwalking? on peripheral events phase operation 1 while in a power save mode where peripheral clocks are asleep, asynchronous generator j sends peripheral event to pevc 2 incoming event is detected by ev s j , and clk_pevc requested to pm 3 upon reception of clock request, pm wakes clock sources if required 4 clk_pevc wakes up
847 42023e?sam?07/2013 atsam4l8/l4/l2 figure 31-3. sleepwalking? on peripheral events 31.5.3 clocks the pevc has two clocks connected: one peri pheral bus clock (clk_pevc) and the system rc oscillator clock (clk_rcsys). these cl ocks are generated by the power manager. clk_pevc is required for event propagati on and peripheral bus operations. clk_rcsys is used for glitch filtering in event shapers. it is required for event propagation in case glitch filtering is turned on for a given generator. 5 incoming event j propagates to channel i: ? clk_user i request to pm ? trig i forwarded to user i 6 clk_user i wakes up 7 user i handles the incoming peripheral event and signals it to pevc 8 depending on the peripheral?s operation, a cpu wake request occurs in case of interrupt processing 9 alternatively, the peripheral may simply go back to sleep, in which case pm will silently shut off clk_user i and clk_pevc table 31-2. sleepwalking? on peripheral events phase operation channel i pevc evs j generator j user i trig i evt j rdy i clk_user i power manager clk_user i wake cpu irq user i 1 2 5 7 8 6 5 4 wake clock sources clk_pevc 3
848 42023e?sam?07/2013 atsam4l8/l4/l2 31.5.4 interrupts pevc can generate an interrupt request in case of trigger generation or trigger overrun. the pevc interrupt request lines are connected to the nvic . using the pevc inte rrupts requires the nvic to be programmed first. 31.5.5 debug operation pevc is not frozen during debug operation when the core is halted, unless the bit correspond- ing to the pevc is set in the peripheral debug register (pdbg). refer to the on-chip debug chapter for details.
849 42023e?sam?07/2013 atsam4l8/l4/l2 31.6 functional description 31.6.1 pevc channel operation pevc routes incoming ev ents to users by mean s of one channel per user. cha nnels operate in parallel, allowing multip le users to listen to the same generator. 31.6.1.1 channel setup the channel multiplexer register (chmxi) is written to allocate a generator to a given channel. the event multiplexer field (evmx) selects between the different generators, while the software event multiplexer bit (smx) selects software events. the channel is then enabled by writing a one to the appropriate bit in the channel enable regis- ter (cher). it is disabled by writing a one to the appropriate bit in the channel disable register (chdr). to safely configure a channel, user software must: ? disable the channel by writing a one to chdr ? configure chmxi ? enable the channel by writing a one to cher 31.6.1.2 channel operation when the channel is enabled, the user signals its busy/ready state to the channel, to determine how an incoming event will be handled: ? if the user is ready, an incoming event is forwarded. the corresponding trigger status register (trisr) bit is set to one allowing an interrupt to be generated for tracking pevc operations. ? if the user is busy (because of a previous event, or for some other cause), the new event is not forwarded. the corresponding overrun status register (ovsr) flag is set allowing an interrupt to be generated. the busy register (busy) is used to determine the current activity of a channel/user. a busy status has one of two causes: ? a peripheral event is being relayed by the channel and handled by the user, ? no event relayed, but user is not ready (e.g. not initialized, or handling some other request). 31.6.1.3 software event a software event can be initiated by writing to the software event register (sev). this is intended for application debugging. the channel must first be configured by writing a one to the software event multiplexer bit (smx) of chmxi. writing a one to the appropriat e bit of sev will then trigger a software event on the channel.
850 42023e?sam?07/2013 atsam4l8/l4/l2 31.6.2 event shaper (evs) operation pevc contains event shapers (evs) for certain types of generators: ? external inputs ? general-purpose waveforms like timer outputs or generic clocks refer to the module configuration section at the end of this chapter for the device-specific con- figuration of event shapers and input glitch filters. each event shaper is re sponsible of shaping on e input, prior to goin g through a pevc channel: ? optionally apply input-glich-filtering ? synchronize incoming events ? request clk_pevc when in deeper sleep modes write a one to the en field of the corresponding event shaper register (evs) to enable operation. 31.6.2.1 input glitch filter (igf) input glitch filtering can be turned on or off by writing to the input glitch filter fields (igfr and igff) of the co rresponding event shap er register (evs). when igf is on, the incoming event is sampled periodically. the sampling clock is divided from clk_rcsys by the value of the inpu t glitch filter divider register (igfdr). igf will filter out spikes and propagate only incoming events that respect one of the following two conditions: ? rise event: 2 samples low, followed by 0+ changes, followed by 2 samples high ? fall event: 2 samples high, followed by 0+ changes, followed by 2 samples low clk_rcsys must be enabled to use input glitch filtering. 31.6.3 event propagation latency once a channel is setup, incoming peripheral events are relayed by hardware. event progation latency is therefore cycle deterministic. however, its value depends on the exact settings that apply to a given channel. when the channel multiplexer ch mxi.evmx selects a generator without event shaper, event propagation latency is 0 cycle. so ftware event is a particular case of 0 cycle propagation. when the channel multiplexer chmxi.evmx selects a generator with event shaper, event prop- agation latency depend s on input glitch filter se tting evsj.igf and sleepwalking?: ? igf off: event propagat ion latency is less or eq ual to 2 clk_pevc cycles ? igf on: event propagation latency is less or equal to 3 * 2 igfdr * clk_rcsys cycles ? in case of sleepwalking? operation, an additional delay incurs if the pm needs to revive the clocks sources. in that particular case of low-power operation, propagation latency is longer and cannot be predicted.
851 42023e?sam?07/2013 atsam4l8/l4/l2 refer to the module configuration section at the end of this chapter for the list of generators implementing event shapers. 31.7 application example this application example shows how the peripheral event system can be used to program the adc interface to perform adc conversions at selected intervals. one of the possible adc conversion trigger is a peripheral event trigger, allowing the peripheral event system to synchronize conversion with some configured peripheral event source. one particular peripheral event source can be an ast peripheral event, among other types of periph- eral events. the peripheral event system can then be used to set up the adc interface to sample an analog signal at regular intervals generated by the ast. the user must enable peripheral events in the ast and in the adc interface. refer to the corre- sponding chapters for how this is accomplished . next, the ast will ge nerate peripheral events periodically, and the peripheral ev ent system will route the peri pheral events to the adc inter- face, which will perform adc conver sions at the selected intervals. figure 31-4. application example since the ast peripheral event is an asynchro nous event, the description above will also work in power save modes where the adc clock is st opped. in this case, the adc clock (and clock source, if needed) will be restarted during t he adc conversion. after the conversi on, the adc clock and clock source will return to the sleep state, unless the adc generate s an interrupt, which in turn will wake up the system. using asynchronous events thus allows adc operation in much lower power states than would otherwise be possible. table 31-3. event propagation latency generator chmxi.evmx input glitch filter evsj.igf latency clock software event - 0 - generator without event shaper - 0 - generator with event shaper off 2 clk_pevc generator with event shaper on 3 * 2 igfdr clk_rcsys asynchronous generator in sleepwalking? operation on or off unpredicted - peripheral event system ast adc interface trigger conversion periodic peripheral event
852 42023e?sam?07/2013 atsam4l8/l4/l2 31.8 user interface notes: 1. the reset values for these register s are device specific. refer to the module configuration section at the end of this chapter. table 31-4. pevc register memory map offset register register name access reset 0x000 channel status register chsr read-only 0x00000000 0x004 channel enable register cher write-only - 0x008 channel disable register chdr write-only - 0x010 software event sev write-only - 0x014 channel / user busy busy read-only - (1) 0x020 trigger interrupt mask enable register trier write-only - 0x024 trigger interrupt mask disable register tridr write-only - 0x028 trigger interrupt mask register trimr read-only 0x00000000 0x030 trigger status register trsr read-only 0x00000000 0x034 trigger status clear register trscr write-only - 0x040 overrun interrupt mask enable register ovier write-only - 0x044 overrun interrupt mask disable register ovidr write-only - 0x048 overrun interrupt mask register ovimr read-only 0x00000000 0x050 overrun status register ovsr read-only 0x00000000 0x054 overrun status clear register ovscr write-only - 0x100 channel multiplexer 0 chmx0 read/write 0x00000000 0x100 + i*4 channel multiplexer i chmxi read/write 0x00000000 0x17c channel multiplexer 31 chmx31 read/write 0x00000000 0x200 event shaper 0 evs0 read/write 0x00000000 0x200 + j*4 event shaper j evsj read/write 0x00000000 0x2fc event shaper 63 evs63 read/write 0x00000000 0x300 input glitch filter divider register igfdr read/write 0x00000000 0x3f8 parameter parameter read-only - (1) 0x3fc version version read-only - (1)
853 42023e?sam?07/2013 atsam4l8/l4/l2 31.8.1 channel status register name: chsr access type: read-only offset: 0x000 reset value: 0x00000000 ? chs: channel status 0: the corresponding channel is disabled. 1: the corresponding channel is enabled. this bit is cleared when the corresponding bit in chdr is written to one. this bit is set when the corresponding bit in cher is written to one. 31 30 29 28 27 26 25 24 chs 23 22 21 20 19 18 17 16 chs 15 14 13 12 11 10 9 8 chs 76543210 chs
854 42023e?sam?07/2013 atsam4l8/l4/l2 31.8.2 channel enable register name: cher access type: write-only offset: 0x004 reset value: - ? che: channel enable writing a zero to this bit has no effect. writing a one to this bit will set the corresponding bit in chsr. 31 30 29 28 27 26 25 24 che 23 22 21 20 19 18 17 16 che 15 14 13 12 11 10 9 8 che 76543210 che
855 42023e?sam?07/2013 atsam4l8/l4/l2 31.8.3 channel disable register name: chdr access type: write-only offset: 0x008 reset value: - ? chd: channel disable writing a zero to this bit has no effect. writing a one to this bit will clear the corresponding bit in chsr. 31 30 29 28 27 26 25 24 chd 23 22 21 20 19 18 17 16 chd 15 14 13 12 11 10 9 8 chd 76543210 chd
856 42023e?sam?07/2013 atsam4l8/l4/l2 31.8.4 software event register name: sev access type: write-only offset: 0x010 reset value: - ? sev: software event writing a zero to this bit has no effect. writing a one to this bit will trigger a software event for the corresponding channel. 31 30 29 28 27 26 25 24 sev 23 22 21 20 19 18 17 16 sev 15 14 13 12 11 10 9 8 sev 76543210 sev
857 42023e?sam?07/2013 atsam4l8/l4/l2 31.8.5 channel / user busy name: busy access type: read-only offset: 0x014 reset value: - ? busy: channel status 0: the corresponding channel and user are idle. 1: the corresponding channel and user are busy. 31 30 29 28 27 26 25 24 busy 23 22 21 20 19 18 17 16 busy 15 14 13 12 11 10 9 8 busy 76543210 busy
858 42023e?sam?07/2013 atsam4l8/l4/l2 31.8.6 trigger interrupt enable register name: trier access type: write-only offset: 0x020 reset value: - ? trie: trigger interrupt enable writing a zero to this bit has no effect. writing a one to this bit will set the corresponding bit in trimr. 31 30 29 28 27 26 25 24 trie 23 22 21 20 19 18 17 16 trie 15 14 13 12 11 10 9 8 trie 76543210 trie
859 42023e?sam?07/2013 atsam4l8/l4/l2 31.8.7 trigger interrupt disable register name: tridr access type: write-only offset: 0x024 reset value: - ? trid: trigger interrupt disable writing a zero to this bit has no effect. writing a one to this bit will clear the corresponding bit in imr. 31 30 29 28 27 26 25 24 trid 23 22 21 20 19 18 17 16 trid 15 14 13 12 11 10 9 8 trid 76543210 trid
860 42023e?sam?07/2013 atsam4l8/l4/l2 31.8.8 trigger interrupt mask register name: trimr access type: read-only offset: 0x028 reset value: 0x00000000 ? trim: trigger interrupt mask 0: the corresponding interrupt is disabled. 1: the corresponding interrupt is enabled. this bit is cleared when the corresponding bit in tridr is written to one. this bit is set when the corresponding bit in trier is written to one. 31 30 29 28 27 26 25 24 trim 23 22 21 20 19 18 17 16 trim 15 14 13 12 11 10 9 8 trim 76543210 trim
861 42023e?sam?07/2013 atsam4l8/l4/l2 31.8.9 trigger status register name: trsr access type: read-only offset: 0x030 reset value: 0x00000000 ? trs: trigger interrupt status 0: an interrupt event has not occurred 1: an interrupt event has occurred this bit is cleared by writing a one to the corresponding bit in trscr. 31 30 29 28 27 26 25 24 trs 23 22 21 20 19 18 17 16 trs 15 14 13 12 11 10 9 8 trs 76543210 trs
862 42023e?sam?07/2013 atsam4l8/l4/l2 31.8.10 trigger status clear register name: trscr access type: write-only offset: 0x034 reset value: - ? trsc: trigger interrupt status clear writing a zero to this bit has no effect. writing a one to this bit will clear the corresponding bit in trsr. 31 30 29 28 27 26 25 24 trsc 23 22 21 20 19 18 17 16 trsc 15 14 13 12 11 10 9 8 trsc 76543210 trsc
863 42023e?sam?07/2013 atsam4l8/l4/l2 31.8.11 overrun interrupt enable register name: ovier access type: write-only offset: 0x040 reset value: - ? ovie: overrun interrupt enable writing a zero to this bit has no effect. writing a one to this bit will set the corresponding bit in ovimr. 31 30 29 28 27 26 25 24 ovie 23 22 21 20 19 18 17 16 ovie 15 14 13 12 11 10 9 8 ovie 76543210 ovie
864 42023e?sam?07/2013 atsam4l8/l4/l2 31.8.12 overrun interrupt disable register name: ovidr access type: write-only offset: 0x044 reset value: - ? ovid: overrun interrupt disable writing a zero to this bit has no effect. writing a one to this bit will clear the corresponding bit in imr. 31 30 29 28 27 26 25 24 ovid 23 22 21 20 19 18 17 16 ovid 15 14 13 12 11 10 9 8 ovid 76543210 ovid
865 42023e?sam?07/2013 atsam4l8/l4/l2 31.8.13 overrun interrupt mask register name: ovimr access type: read-only offset: 0x048 reset value: 0x00000000 ? ovim: overrun interrupt mask 0: the corresponding interrupt is disabled. 1: the corresponding interrupt is enabled. this bit is cleared when the corresponding bit in ovidr is written to one. this bit is set when the corresponding bit in ovier is written to one. 31 30 29 28 27 26 25 24 ovim 23 22 21 20 19 18 17 16 ovim 15 14 13 12 11 10 9 8 ovim 76543210 ovim
866 42023e?sam?07/2013 atsam4l8/l4/l2 31.8.14 overrun status register name: ovsr access type: read-only offset: 0x050 reset value: 0x00000000 ? ovs: overrun in terrupt status 0: an interrupt event has not occurred 1: an interrupt event has occurred this bit is cleared by writing a one to the corresponding bit in ovscr. 31 30 29 28 27 26 25 24 ovs 23 22 21 20 19 18 17 16 ovs 15 14 13 12 11 10 9 8 ovs 76543210 ovs
867 42023e?sam?07/2013 atsam4l8/l4/l2 31.8.15 overrun status clear register name: ovscr access type: write-only offset: 0x054 reset value: - ? ovsc: overrun inte rrupt status clear writing a zero to this bit has no effect. writing a one to this bit will clear the corresponding bit in ovsr. 31 30 29 28 27 26 25 24 ovsc 23 22 21 20 19 18 17 16 ovsc 15 14 13 12 11 10 9 8 ovsc 76543210 ovsc
868 42023e?sam?07/2013 atsam4l8/l4/l2 31.8.16 channel multiplexer register name: chmxi access type: read/write offset: 0x100 + i*0x004 reset value: 0x00000000 ? smx: software event multiplexer 0: the software event is not selected. event / generator is selected by evmx. 1: the software event is selected. evmx is not considered. ? evmx: event multiplexer select input event / generator. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------smx 76543210 - - evmx smx evmx channel input 1 any software event 0 0x00 evt0 0 0x01 evt1 0 0xj evtj 0 > trigout none
869 42023e?sam?07/2013 atsam4l8/l4/l2 31.8.17 event shaper register name: evsj access type: read/write offset: 0x200 + j*0x004 reset value: 0x00000000 ? igfon: input glitch filter status 0: input glitch filter is off. 1: input glitch filter is on. only present when igf is used. refer to the module configuration section at the end of this chapter. to enable input glitch filtering, en bit must be set to 1, as well as one of igff or igfr. this bit is read-only, and can be used to detect that configurat ion is effective. it incurs some delay compared to the writing of igff, igfr, or en. ? igff: input glitch filter fall 0: no event detection on falling edge. 1: event detection through input glitch fiilter on falling edge. only present when igf is used. refer to the module configuration section at the end of this chapter. to enable input glitch filtering, en bit must also be set to 1. both igff and igfr can be combined. ? igfr: input glitch filter rise 0: no event detection on rising edge. 1: event detection through inpu t glitch fiilter on rising edge. only present when igf is used. refer to the module configuration section at the end of this chapter. to enable input glitch filtering, en bit must also be set to 1. both igff and igfr can be combined. ? en: event shaper enable 0: event shaper is off. 1: event shaper is on. to enable input glitch filtering, igfr and/or igff must also be set to 1. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 - - - - - igfon igff igfr 15 14 13 12 11 10 9 8 -------- 76543210 -------en
870 42023e?sam?07/2013 atsam4l8/l4/l2 31.8.18 input glitch fi lter divider register name: igfdr access type: read/write offset: 0x300 reset value: 0x00000000 ? igfdr: input glitch filter divider selects prescaler division ratio for the system rc clock used for glitch filtering. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------- 76543210 ---- igfdr igfdr division ratio 0x0 1 0x1 2 0x2 4 0xn 2 n 0xf 32768
871 42023e?sam?07/2013 atsam4l8/l4/l2 31.8.19 parameter register name: parameter access type: read-only offset: 0x3f8 reset value: - ? trigout: number of trigger outputs / channels / users number of trigger outputs / channels implemented. no functionality associated. ? evin: number of event inputs / generators number of event inputs. no functionality associated. ? evs_count: number of event shapers number of event shapers implement ed. no functionality associated. ? igf_count: number of input glitch filters number of input glitch filters implemented. no functionality associated. 31 30 29 28 27 26 25 24 trigout 23 22 21 20 19 18 17 16 evin 15 14 13 12 11 10 9 8 evs_count 76543210 igf_count
872 42023e?sam?07/2013 atsam4l8/l4/l2 31.8.20 version register name: version access type: read-only offset: 0x3fc reset value: - ? variant: variant number variant number of the module. no functionality associated. ? version: version number version number of the module. no functionality associated. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 ---- variant 15 14 13 12 11 10 9 8 - - - - version[11:8] 76543210 version[7:0]
873 42023e?sam?07/2013 atsam4l8/l4/l2 31.9 module configuration the specific configuration for each pevc instance is listed in the following tables. the module bus clocks listed here are connected to the system bus clocks. refer to section 10. ?power manager (pm)? on page 108 for details. the module register reset values are listed below. the following table defines generators and input events connected to the peripheral event sys- tem. it also specifies whether event shaper and input glitch filter are implemented for this generator, and if sleepwalking is available. table 31-5. module clock name module name clock name pevc clk_pevc table 31-6. register reset values register reset value version 0x00000200 parameter 0x131f1204 busy 0x0002401f table 31-7. generators chmxn.evmx generator - inpu t event igf evs sleepwalking 0 pad_evt 0 - change on input pin yes yes yes 1 pad_evt 1 - change on input pin yes yes yes 2 pad_evt 2 - change on input pin yes yes yes 3 pad_evt 3 - change on input pin yes yes yes 4 gclk 8 - rising edge yes 5 gclk 9 - rising edge yes 6 ast - alarm event 0 yes yes 7reserved 8 ast - periodic event 0 yes yes 9reserved 10 ast - overflow event yes yes 11 acifc - ac0 vinp>vinn 12 acifc - ac1 vinp>vinn 13 acifc - ac2 vinp>vinn 14 acifc - ac3 vinp>vinn 15 acifc - ac0 vinp 874 42023e?sam?07/2013 atsam4l8/l4/l2 the following table defines users connected to the peripheral event system, and their corre- sponding triggered action. it also specifies w heter sleepwalking is available for each user. 19 acifc - ac0-ac1 window 20 acifc - ac2-ac3 window 21 tc0 - a0 waveform mode rising edge yes 22 tc0 - a1 waveform mode rising edge yes 23 tc0 - a2 waveform mode rising edge yes 24 tc0 - b0 waveform mode rising edge yes 25 tc0 - b1 waveform mode rising edge yes 26 tc0 - b2 waveform mode rising edge yes 27 adc - window match 28 adc - end of conversion 29 vregifg - stop switching ready 30 picouart - character reception yes yes table 31-8. users channel number user - trig erred action sleepwalking 0 pdca - channel 0 transfer one word 1 pdca - channel 1transfer one word 2 pdca - channel 2 transfer one word 3 pdca - channel 3 transfer one word 4 adc - start one conversion yes 5 dac - start one conversion 6 catb - trigger one autonomous touch sensing yes 7reserved 8 tc1 - a0 capture 9 tc1 - a1 capture 10 tc1 - a2 capture 11 tc1 - b0 capture 12 tc1 - b1 capture 13 tc1 - b2 capture 14 acifc - trigger one comparison yes 15 parc - parrallel capture start 16 parc - parrallel capture stop 17 vregifg - stop switching request yes 18 vregifg - stop switching disable yes table 31-7. generators chmxn.evmx generator - inpu t event igf evs sleepwalking
875 42023e?sam?07/2013 atsam4l8/l4/l2
876 42023e?sam?07/2013 atsam4l8/l4/l2 32. audio bit stream dac (abdacb) rev: 1.0.0.0 32.1 features ? 16 bit digital stereo dac ? oversampling d/a conversion architecture ? adjustable oversampling ratio ? 3rd order sigma-delta d/a converters ? digital bitstream output ? parallel interface ? connects to dma for background tr ansfer without cpu intervention ? supported sampling frequencies ? 8000hz, 11025hz, 12000hz, 16000hz, 22050hz, 24000hz, 32000hz, 44100hz, and 48000hz ? supported data formats ? 32-, 24-, 20-, 18-, 16-, and 8-bit stereo format ? 16- and 8-bit compact stereo format, with left and right sample packed in the same word to reduce data transfers ? common mode offset control ? volume control 32.2 overview the audio bitstream dac (abdacb) converts a 16- bit sample value to a digital bitstream with an average value proportional to the sample value. two channels are supported making the audio bitstream dac particularly suitable for st ereo audio. each channel has a pair of comple- mentary digital outputs, dac and dacn, which can be connected to an external high input impedance amplifier. the audio bitstream dac is made up of several si gnal processing blocks and a 3rd order sigma delta d/a converter for each channel. the sigma delta modulator converts the parallel data to a bitstream, while the signal processing blocks perform volume control, offset control, upsampling, and filtering to compensate for the upsampling process. the upsampling is performed by a cas- caded integrator-comb (cic) filter, and the compensation filter is a finite impulse response (fir) cic compensation filter. 32.3 block diagram figure 32-1. abdacb block diagram u s e r i n t e r f a c e synchronizer volume control offset control cic compensation filter (fir) cic comb section cic integrator section clock divider sigma delta modulator sigma delta modulator clk_abdacb gclk signal processing (before up-sampling) clk dac[0] dacn[0] dac[1] dacn[1] pb
877 42023e?sam?07/2013 atsam4l8/l4/l2 32.4 i/o lines description 32.5 product dependencies in order to use this module, other parts of the system must be configured correctly, as described below. 32.5.1 i/o lines the output pins used for the output bitstream from the audio bitstream dac may be multiplexed with i/o controller lines. before using the audio bitstream dac, the i/o controller must be configured in order for the audio bitstream dac i/o lines to be in audio bitstream dac peripheral mode. 32.5.2 clocks the clock for the abdacb bus interface (clk_abd acb) is generated by the power manager. it is recommended to disable the abdacb before di sabling the clock, to avoid freezing the abdacb in an undefined state. before using the audio bitstream dac, the user must ensure that the audio bitstream dac clock is enabled in the power manager. the audio bitstream dac requires a separate cloc k for the d/a conversion. this clock is pro- vided by a generic clock which has to be set up in the system control interface (scif). the frequency for this clock has to be set as described in table 32-3 on page 886 . it is important that this clock is accurate and has low jitter. incorrect frequen cy will result in too fast or too slow play- back (frequency shift) , and too high jitter will add noise to the d/a conversion. for best performance one should trade frequency accuracy (within some limits) for low jitter to obtain the best performance as jitter will ha ve large impact on the qua lity of the conv erted signal. 32.5.3 dma the abdacb is connected to the peripheral dma controller. using dma to transfer data sam- ples requires the peripheral dma controller to be programmed before enabling the abdacb. 32.5.4 interrupts the abdacb interrupt request line is connecte d to the nvic. using the abdacb interrupt requires the nvic to be programmed first. table 32-1. i/o lines description pin name pin description type dac[0] output for channel 0 output dacn[0] inverted output for channel 0 output dac[1] output for channel 1 output dacn[1] inverted output for channel 1 output clk clock output for dac output
878 42023e?sam?07/2013 atsam4l8/l4/l2 32.6 functional description 32.6.1 construction the audio bitstream dac is divided into several pa rts, the user interface, the signal processing blocks, and the sigma delta modulator blocks. see figure 32-1 on page 876 . the user interface is used to configure the signal processing bl ocks and to input new data samples to the con- verter.the signal processing blocks manages volume control, offset control, and upsampling. the sigma delta blocks converts the parallel data to1-bit bitstreams. 32.6.1.1 cic interpolation filter the interpolation filter in the system is a ca scaded integrator-comb (cic) interpolation filter which interpolates from f s to {125, 128, 136}xf s depending on the control settings. this filter is a 4th order cic filter, and the basic building blocks of the filter is a comb part and an integrator part. since the cic interpolator has a sinc-functi on frequency response it is compensated by a linear phase cic compensation filter to make the passband response more flat in the range 0- 20khz, see figure figure 32-4 on page 882 . the frequency response of this type of interpolator has the first zero at the input sampling frequency. this means that the first repeated specters created by the upsampling process will not be fully rejected and the output signal will contain sig- nals from these repeated specters. see figure 32-6 on page 883 . since the human ear can not hear frequencies above 20khz, we should not be affected by this when the sample rate is above 40khz, but digital measurement equipment will be affected. this need to be accounted for when doing measurements on the system to prevent aliasing and incorrect measurement results. 32.6.1.2 sigma delta modulator the sigma delta modulator is a 3rd order modulator consisting of three differentiators (delta blocks), three integrators (sigma blocks), and a one bit quantizer. the purpos e of the integrators is to shape the noise, so that the noise is reduced in the audio passband and increased at the higher frequencies, where it can be filtered out by an analog low-pass filter. to be able to filter out all the noise at high frequencies the analog low-pass filter must be one order larger than the sigma delta modulator. 32.6.1.3 recreating the analog signal since the dac and dacn outputs from the abdac are digital square wave signals, they have to be passed through a low pass filter to recreate the analog signal. this also means that noise on the io voltage will couple through to the analog signal. to remove some of the io noise the abdac can output a clock signal, clk, which can be used to resample the dac and dacn sig- nals on external flip-flops powered by a clean supply. 32.6.2 initialization before enabling the abdacb the correct confi guration must be applied to the control register (cr). configuring the alternat ive upsampling ratio bit (cr.altupr), common mode offset control bit (cr.cmoc), and the sampling fre quency field (cr.fs) according to the sampling rate of the data that is converted and the type of amplifier the outputs are connected to is required to get the correct behavior of the system. when the correct configuration is applied the abdacb can be enabled by writing a one to the enable bit in the control register (cr.en). the module is disabled by writing a zero to the enable bit. the module should be disabled before entering sleep modes to ensure that the outputs are not left in an undesired state.
879 42023e?sam?07/2013 atsam4l8/l4/l2 32.6.3 basic operation to convert audio data to a digital bitstream the user must first initialize the abdacb as described in section 32.6.2 . when the abdacb is initialized and enabled it will indi cate that it is ready to receive new data by setting the transmit ready bit in the status register (sr.txrdy). when the txrdy bit is set in the status register the user has to write new samples to sample data register 0 (sdr0) and sample data register 1 (sdr1). if the mono mode (mono) bit in the control register (cr) is set, or one of the compact stereo formats are used by configuring the data word format (dataformat) in the control register, only sdr0 has to be written. failing to write to the sample data registers wi ll result in an underrun indicated by the transmit underrun (txur) bit in the status register (s r.txur). when new samples are written to the sample data registers the txrdy bit will be cleared. to increase performance of the system an interr upt handler or dma transfer can be used to write new samples to the sample data registers. see section 32.6.10 for details on dma, and section 32.6.11 for details on interrupt. 32.6.4 data format the input data type is two?s complement. the audio bitstream dac can be configured to accept different audio formats. the format must be configured in the data word format field in the con- trol register. in regular operation data for the two channels are written to the sample data registers sdr0 and sdr1. if the data format fiel d specifies a format using less than 32 bits, data must be written right-justified in sdr0 and sdr1. sign extension into the unused bits is not nec- essary. only the 16 most significant bits in the data will be used by the abdacb. for data formats larger than 16 bits the least significant bits are ignored. for 8-bit data formats the 8 bits will be used as the most significan t bits in the 16-bit samples, th e additional bits will be zeros. the abdacb also supports compact data formats for 16- and 8-bit samples. for 16-bit samples the sample for channel 0 must be written to bits 15 through 0 and the sample for channel 1 must be written to bits 31 through 16 in sdr0. for 8-bit samples the sample for channel 0 must be written to bits 7 through 0 and the sample for channel 1 must be written to bits 15 through 8 in sdr0. sdr1 is not used in this mode. see table 32-5 on page 888 . 32.6.5 data swapping when the swap channels (swap) bit in the control register (cr.swap) is one, writing to the sample data register 0 (sdr0) will put the data in sample data register 1 (sdr1). writing sdr1 will put the data in sdr0. if one of the two compact stereo formats is used the lower and upper halfword of sdr0 will be sw apped when writing to sdr0. 32.6.6 common mode offset control when the common mode offset control (cmoc) bit in the control register is one the input data will get a dc value applied to it and the amplitude will be scaled. this will make the common mode offset of the two corresponding outputs, dac and dacn, to move away from each other so that the output signals are not overlapping. th e result is that the two signals can be applied to a differential analog filter, and the difference will always be a positive value, removing the need for a negative voltage supply for the filter. the cost of doing this a 3db loss in dynamic range. on the left side of figure 32-2 one can see the filtered output from the dac and dacn pins when a sine wave is played when cr.cmoc is zero. th e waveform on the right side shows the output of the differential filter when the two outputs on the left side are used as inputs to the differential filter. figure 32-3 show the corresponding outputs when cr.cmoc is one.
880 42023e?sam?07/2013 atsam4l8/l4/l2 figure 32-2. output signals with cmoc=0 figure 32-3. output signals with cmoc=1 32.6.7 volume control the audio bitstream dac have two volume contro l registers, volume co ntrol register 0 (vcr0) and volume control register 1 (vcr1), that can be used to adjust the volume for the corre- sponding channel. the volu me control is linear and will only sca le each sample according to the value in the volume control (volume) field in the volume control registers. the register also has a mute bit (mute) which can be used to mute the corresponding channel. the filtered out-
881 42023e?sam?07/2013 atsam4l8/l4/l2 put of the dac pins will have a vo ltage given by the follo wing equation, given th at it is configured to run at the default upsampling ratio of 128: if one want to get coherence between the sign of the input data and the output voltage one can use the datan outputs or invert the sign of the input data by software. 32.6.8 mono when the mono bit (mono) in the control register is set, data written to sdr0 will be used for both output channels. if one of the compact stereo formats are used only the data written to the part of sdr0 that corresponds with channel 0 is used. 32.6.9 alternative upsampling ratio the digital filters and sigma delta modulators requires its own clock to perform the conversion at the correct speed, and this clock is provided by a generic clock in the scif. the frequency of this clock depends on the input sample rate and the upsampling ratio which is controlled by the alternative upsampling ratio bit (altupr) in the control register. the abdacb supports three upsampling ratios, 125, 128, and 136. the default setting is a ratio of 128, and is used when cr.altupr is zero. using this ratio gives a clock frequency require- ment that is common for audio products. in some cases one may want to use other clock frequencies that already are available in the system. by writing a one to cr.altupr a upsam- pling ratio of 125 or 136 is used depending on the configuration of the sampling frequency field in the control re gister. refer to table 32-3 for required clock frequency and settings. the required clock frequency of the generic clock can be calculated from the following equation: r is the upsampling ratio of the converter. if cr .altupr is zero the upsampling ratio is 128. if cr.altupr is one, r will change to 125 when cr .fs is configured for 8khz, 12khz, 16khz, 24khz, 32khz, and 48khz. for the other configurations of cr.fs, 11.025khz, 22.050khz, and 44.100khz, it will change to 136. 32.6.10 dma operation the audio bitstream dac is connected to the peripheral dma controller. the peripheral dma controller can be programmed to automatically transfer samples to the sample data registers (sdr0 and sdr1) when the audio bitstream da c is ready for new samples. two dma chan- nels are used, one for each sample data register. if the mono mode bit in the control register (cr.mono) is one, or one of the compact stereo formats is used, only the dma channel con- nected to sdr0 will be used. when using dma only the control re gister needs to be written in the audio bitstream dac. this enables the a udio bitstream dac to operate without any cpu intervention such as polling the status register (sr) or using interrupts. see the peripheral dma controller documentation for details on how to setup peripheral dma transfers. 32.6.11 interrupts the abdacb requires new data samples at a rate of f s . the interrupt status bits are used to indicate when the system is ready to receive new samples. the transmit ready interrupt status bit in the status register (sr.txrdy) will be set whenever the abdacb is ready to receive a new sample. a new sample value must be written to the sample data registers (sdr0 and v out 1 2 -- - 33 128 --------- - ? sdr 2 15 ------------ volume 2 15 1 ? ------------------------ - ?? ?? ?? v vddio ? = gclk[hz] f s r8 ?? =
882 42023e?sam?07/2013 atsam4l8/l4/l2 sdr1) before 1/f s second, or an underrun will occur, as indicated by the underrun interrupt bit in sr (sr.txur). the interrupt bits in sr are cleared by writing a one to the corresponding bit in the status clea r register (scr). 32.6.12 frequency response figure figure 32-4 to figure 32-7 show the frequency response for the system. the sampling frequency used is 48khz, but the response will be the same for othe r sampling frequencies, always having the first zero at f s . figure 32-4. passband frequency response
883 42023e?sam?07/2013 atsam4l8/l4/l2 figure 32-5. frequency response up to sampling frequency figure 32-6. frequency response up to 3x sampling frequency
884 42023e?sam?07/2013 atsam4l8/l4/l2 figure 32-7. frequency response up to 128x sampling frequency
885 42023e?sam?07/2013 atsam4l8/l4/l2 32.7 user interface note: 1. the reset values are device specific. refer to the module configuration section at the end of this chapter. table 32-2. abdacb register memory map offset register register name access reset 0x00 control register cr read/write 0x00000000 0x04 sample data register 0 sdr0 read/write 0x00000000 0x08 sample data register 1 sdr1 read/write 0x00000000 0x0c volume control register 0 vcr0 read/write 0x00000000 0x10 volume control register 1 vcr1 read/write 0x00000000 0x14 interrupt enable register ier write-only 0x00000000 0x18 interrupt disable register idr write-only 0x00000000 0x1c interrupt mask register imr read-only 0x00000000 0x20 status register sr read-only 0x00000000 0x24 status clear register scr write-only 0x00000000 0x28 parameter register pa r a m e t e r read-only - (1) 0x2c version register version read-only - (1)
886 42023e?sam?07/2013 atsam4l8/l4/l2 32.7.1 control register name: cr access type: read/write offset: 0x00 reset value: 0x00000000 ? fs: sampling frequency must be set to the matching data sampling frequency, see table 32-3 . note: 1. the actual clock requirement are 11.9952 mhz, 23.9904mhz, and 47.9808mhz, but this is very close to the suggested clock frequencies, and will only result in a very small frequency shift. this need to be accounted for during testing if comparing to a reference signal. notes: 1. 31 30 29 28 27 26 25 24 ---- fs 23 22 21 20 19 18 17 16 ----- dataformat 15 14 13 12 11 10 9 8 -------- 76543210 swrst - mono cmoc altupr - swap en table 32-3. generic clock requirements cr.fs description gclk (cr.altupr=1) gclk (cr.altupr=0) 0 8000hz sampling frequency 8.0mhz 8.1920mhz 1 11025hz sampling frequency 12.0mhz (1) 11.2896mhz 2 12000hz sampling frequency 12.0mhz 12.2880mhz 3 16000hz sampling frequency 16.0mhz 16.3840mhz 4 22050hz sampling frequency 24.0mhz (1) 22.5792mhz 5 24000hz sampling frequency 24.0mhz 24.5760mhz 6 32000hz sampling frequency 32.0mhz 32.7680mhz 7 44100hz sampling frequency 48.0mhz (1) 45.1584mhz 8 48000hz sampling frequency 48.0mhz 49.1520mhz other reserved - -
887 42023e?sam?07/2013 atsam4l8/l4/l2 ? dataformat: data word format ? swrst: software reset writing a zero to this bit does not have any effect. writing a one to this bit will reset the abdacb as if a hardware reset was done. ? mono: mono mode 0: mono mode is disabled. 1: mono mode is enabled. ? cmoc: common mode offset control 0: common mode adjustment is disabled. 1: common mode adjustment is enabled. ? altupr: alternativ e upsampling ratio 0: alternative upsampling is disabled. 1: alternative upsampling is enabled. ? swap: swap channels 0: channel swap is disabled. 1: channel swap is enabled. ? en: enable 0: the abdacb is disabled. 1: the abdacb is enabled. table 32-4. data word format dataformat word length comment 0 32 bits 1 24 bits 2 20 bits 3 18 bits 4 16 bits 5 16 bits compact stereo channel 1 sample in bits 31 thro ugh 16, channel 0 sample in bits 15 through 0 in sdr0 6 8 bits 7 8 bits compact stereo channel 1 sample in bits 15 through 8, channel 0 sample in bits 7through 0 in sdr0
888 42023e?sam?07/2013 atsam4l8/l4/l2 32.7.2 sample data register 0 name: sdr0 access type: read/write offset: 0x04 reset value: 0x00000000 ? data: sample data sample data for channel 0 in two?s complement format. data must be right-justified, see table 32-5 . 31 30 29 28 27 26 25 24 data[31:24] 23 22 21 20 19 18 17 16 data[23:16] 15 14 13 12 11 10 9 8 data[15:8] 76543210 data[7:0] table 32-5. sample data register formats data format sdr0 sdr1 comment 32 bits ch0 sample in data[31:0] ch1 sample in data[31:0] 24 bits ch0 sample in data[23:0] ch1 sample in data[23:0] remaining bits are ignored. 20 bits ch0 sample in data[19:0] ch1 sample in data[19:0] remaining bits are ignored. 18 bits ch0 sample in data[17:0] ch1 sample in data[17:0] remaining bits are ignored. 16 bits ch0 sample in data[15:0] ch1 sample in data[15:0] remaining bits are ignored. 16 bits compact stereo ch0 sample in data[15:0] ch1 sample in data[31:16] not used 8 bits ch0 sample in data[7:0] ch1 sample in data[7:0] remaining bits are ignored. 8 bits compact stereo ch0 sample in data[7:0] ch1 sample in data[15:8] not used remaining bits are ignored.
889 42023e?sam?07/2013 atsam4l8/l4/l2 32.7.3 sample data register 1 name: sdr1 access type: read/write offset: 0x08 reset value: 0x00000000 ? data: sample data sample data for channel 1 in two?s complement format. data must be right-justified, see table 32-5 on page 888 . 31 30 29 28 27 26 25 24 data[31:24] 23 22 21 20 19 18 17 16 data[23:16] 15 14 13 12 11 10 9 8 data[15:8] 76543210 data[7:0]
890 42023e?sam?07/2013 atsam4l8/l4/l2 32.7.4 volume control register 0 name: vcr0 access type: read/write offset: 0x0c reset value: 0x00000000 ? mute: mute 0: channel 0 is not muted. 1: channel 0 is muted. ? volume: volume control 15-bit value adjusting the volume for channel 0. 31 30 29 28 27 26 25 24 mute------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 - volume[14:8] 76543210 volume[7:0]
891 42023e?sam?07/2013 atsam4l8/l4/l2 32.7.5 volume control register 1 name: vcr1 access type: read/write offset: 0x10 reset value: 0x00000000 ? mute: mute 0: channel 1 is not muted. 1: channel 1 is muted. ? volume: volume control 15-bit value adjusting the volume for channel 1. 31 30 29 28 27 26 25 24 mute------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 - volume[14:8] 76543210 volume[7:0]
892 42023e?sam?07/2013 atsam4l8/l4/l2 32.7.6 interrupt enable register name: ier access type: write-only offset: 0x14 reset value: 0x00000000 writing a zero to a bit in this register has no effect. writing a one to a bit in this register will set the corresponding bit in imr. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------- 76543210 -----txurtxrdy-
893 42023e?sam?07/2013 atsam4l8/l4/l2 32.7.7 interrupt disable register name: idr access type: write-only offset: 0x18 reset value: 0x00000000 writing a zero to a bit in this register has no effect. writing a one to a bit in this register will clear the corresponding bit in imr. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------- 76543210 -----txurtxrdy-
894 42023e?sam?07/2013 atsam4l8/l4/l2 32.7.8 interrupt mask register name: imr access type: read-only offset: 0x1c reset value: 0x00000000 0: the corresponding interrupt is disabled. 1: the corresponding interrupt is enabled. a bit in this register is cleared when the corresponding bit in idr is written to one. a bit in this register is set when the corresponding bit in ier is written to one. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------- 76543210 -----txurtxrdy-
895 42023e?sam?07/2013 atsam4l8/l4/l2 32.7.9 status register name: sr access type: read-only offset: 0x20 reset value: 0x00000000 ? txur: transmit underrun this bit is cleared when no underrun has occurred since the last time this bit was cleared (by reset or by writing to scr). this bit is set when at least one underrun has occurred since the last time this bit was cleared (by reset or by writing to scr ). ? txrdy: transmit ready this bit is cleared when the abdacb is not ready to receive a new data in sdr. this bit is set when the abdacb is ready to receive a new data in sdr. ? busy: abdacb busy this bit is set when the abdacb is busy doing a data transfer between clock domains. cr, sdr0, and sdr1 can not be written during this time. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------- 76543210 -----txurtxrdybusy
896 42023e?sam?07/2013 atsam4l8/l4/l2 32.7.10 status clear register name: scr access type: write-only offset: 0x24 reset value: 0x00000000 writing a zero to a bit in this register has no effect. writing a one to a bit in this register will clear the corresponding bit in sr and the corresponding interrupt request. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------- 76543210 -----txurtxrdy-
897 42023e?sam?07/2013 atsam4l8/l4/l2 32.7.11 parameter register name: parameter access type: read-only offset: 0x28 reset value: 0x00000000 reserved. no functionality associated. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------- 76543210 --------
898 42023e?sam?07/2013 atsam4l8/l4/l2 32.7.12 version register name: version access type: read-only offset: 0x2c reset value: 0x00000000 ? variant: variant number reserved. no functionality associated. ? version: version number version number of the module. no functionality associated. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 ---- variant 15 14 13 12 11 10 9 8 ---- version[11:8] 76543210 version[7:0]
899 42023e?sam?07/2013 atsam4l8/l4/l2 32.8 module configuration the specific configuration for each abdacb inst ance is listed in the following tables.the module bus clocks listed here are connected to the system bus clocks. refer to section 10. ?power man- ager (pm)? on page 108 for details. table 32-6. abdacb clocks clock name description clk_abdacb clock for the abdacb bus interface gclk the generic clock used for the abdacb is gclk6 table 32-7. register reset values register reset value version 0x00000100 parameter 0x00000000
900 42023e?sam?07/2013 atsam4l8/l4/l2 33. digital to analog converter controller (dacc) rev. 1.1.1.0 33.1 features ? 10-bit resolution ? hardware trigger ? external trigger pins ? peripheral event ? pdca support ? dacc timings configuration ? internal fifo for flexibility and efficiency 33.2 overview the digital-to-analog converter controller (dacc) supports 10-bit resolution. data to be con- verted are sent in a common register. external triggers, through ext_trig pins, and internal triggers (events) are configurable. the dacc connects with a pdca channel reducing and processor intervention. user can configure dacc timings, such as startup time and internal trigger period.
901 42023e?sam?07/2013 atsam4l8/l4/l2 33.3 block diagram figure 33-1. digital-to-analog converter controller block diagram 33.4 signal description 33.5 product dependencies 33.5.1 clocks dacc uses bus interface clock (clk_dacc) which is generated by the power manager. it is recommended to disable the dacc before disabling the clock, to avoid freezing the dacc in an undefined state. trigger selection control logic interrupt controller pdca user interface analog cell dac core ext_trig sample & hold vout dac controller apb peripheral event table 33-1. dacc pin description pin name description vout analog output ext_trig external trigger
902 42023e?sam?07/2013 atsam4l8/l4/l2 33.5.2 interrupt sources the dacc interrupt line is connected on one of the internal sources of the nvic. using the dacc interrupt requires the nvic to be programmed first. 33.6 functional description 33.6.1 digital-to-analog conversion dacc uses the apb clock (clk_dacc) to perform conversions. dac is enabled by writing a one to dacen in mo de register (mr). once enabled, dac is ready to operate after a startup time (see electrical characteristics). user must therefore configure startup time by writing new value in mr.startup, according to apb clcok frequency. startup time is therefore (mr.startup+1) * apb clock period. once a conversion is started, dac requires setup time before providing analog result on the analog pin vout (see electrical characteristics). 33.6.2 conversion fifo to provide flexibility and high ef ficiency, a 4 half-wo rd fifo is used to handle the data to convert. as long as the transmit ready bit (txrdy) in the interrupt status register (isr) is set to one the dac controller accepts new conversion r equests by writing data to the conversion data register (cdr). data which cannot be converted immediately are stored in the fifo. when the fifo is full or the da cc is not ready to accept conv ersion requests, txrdy is low. writing to cdr while txrdy is low corrupts fifo data. user can configure transfer data size. when bit word in mr is set to one transfer size is 16 bits and when word is set to one tran sfer size is 32 bits. in 16 bits transfer size, data to convert is cdr[9:0] and in 32 bits transfer size, data to convert are cdr[9:0] (first data to convert) and cdr[25:16] (second data to convert). 33.6.3 conversion triggers internal trigger mode is selected by writing a zero to trigger enable (mr.trgen). in internal trigger mode, conversion starts as soon as dac is enabled, data is written in the conversion data register (cdr) and internal trigger event occurs. the internal trigger frequency is configu- rable through the mr.clkdiv and must not exceed the maximum frequency allowed by the dac. trigger period is ther efore clkdiv * apb clock period. external trigger mode is selected by writing a one to mr.trgen. the external event source is configured by writing a zero to trigger select (m r.trgsel) to select external pin ext_trg and a one to select the peripheral event (from pevc). with ex ternal pin source, dacc waits for a rising edge to begin conversion. with peripheral event source, dacc waits for event (config- ured by pevc) to begin conversion.
903 42023e?sam?07/2013 atsam4l8/l4/l2 figure 33-2. internal trigger figure 33-3. external trigger 33.6.4 write protection registers in order to provide security to the dacc, a write protection mode is implemented. this mode is enabled by writing a one in write protect enabl e (wpe) in the write protect mode register (wpmr) and disabled by writin g a zero. writing to wpmr requires to write a security key in write protect key (wpmr.wpkey). the value is ?dac? in ascii, corr esponding to 0x444143. the write protection mode prevents the write of mode register. when this mode is enabled and the protected registers is written, an error is generated in the write protect status register (wpsr) and the register write request is canc eled. when a write protection error occurs, the write protection error bit (wproterr) is set to one.
904 42023e?sam?07/2013 atsam4l8/l4/l2 33.7 user interface note: 1. the reset value is device specific. refer to the module configuration section at the end of this chapter. table 33-2. dacc register memory map offset register register name access reset 0x00 control register cr write-only ? 0x04 mode register mr read-write 0x00000000 0x08 conversion data register cdr write-only 0x00000000 0x0c interrupt enable register ier write-only ? 0x10 interrupt disable register idr write-only ? 0x14 interrupt mask register imr read-only 0x00000000 0x18 interrupt status register isr read-only 0x00000000 0xe4 write protect mode register wpmr read-write 0x00000000 0xe8 write protect status register wpsr read-only 0x00000000 0xfc version register version read-only 0x- (1)
905 42023e?sam?07/2013 atsam4l8/l4/l2 33.7.1 control register name: cr access type: write-only offset: 0x00 reset value: - ? swrst: software reset writing a one to this bit resets the dacc. writing a zero to this bit has no effect. 31 30 29 28 27 26 25 24 ???????? 23 22 21 20 19 18 17 16 ???????? 15 14 13 12 11 10 9 8 ???????? 76543210 ???????swrst
906 42023e?sam?07/2013 atsam4l8/l4/l2 33.7.2 mode register name: mr access: read/write offset: 0x04 reset value: 0x00000000 this register can only be written if the wpen bit is cleared in write protect mode register. ? clkdiv: clock divider for internal trigger trigger period is clkd iv * apb clock period. ? startup: startup time selection starup time is (startup + 1) * apb clock period. ? word: word transfer ? dacen: dac enable writing a one to this bit enables the dac. writing a zero to this bit disables the dac. ? trgsel: trigger selection ? trgen: trigger enable 0: internal trigger mode. 1: external trigger mode. 31 30 29 28 27 26 25 24 clkdiv 23 22 21 20 19 18 17 16 clkdiv 15 14 13 12 11 10 9 8 startup 76543210 ? ? word dacen trgsel trgen word selected resolution 0 half-word transfer (16 bits) 1 word transfer (32 bits) trgsel selected trgsel 0 0 0 external trigger 0 0 1 peripheral event 010reserved 011reserved 100reserved 101reserved 110reserved 111reserved
907 42023e?sam?07/2013 atsam4l8/l4/l2 33.7.3 conversion data register name: cdr access: write-only offset: 0x08 reset value: 0x00000000 ? data: data to convert when the mr.word is zero, only data[15:0] is used for conversi on else data[31:0] is used to write 2 data for conversion. 31 30 29 28 27 26 25 24 data 23 22 21 20 19 18 17 16 data 15 14 13 12 11 10 9 8 data 76543210 data
908 42023e?sam?07/2013 atsam4l8/l4/l2 33.7.4 interrupt enable register name: ier access: write-only offset: 0x0c reset value: - writing a zero to a bit in this register has no effect. writing a one to a bit in this register will set the corresponding bit in imr. 31 30 29 28 27 26 25 24 ???????? 23 22 21 20 19 18 17 16 ???????? 15 14 13 12 11 10 9 8 ???????? 76543210 ???????txrdy
909 42023e?sam?07/2013 atsam4l8/l4/l2 33.7.5 interrupt disable register name: idr access: write-only offset: 0x10 reset value: - writing a zero to a bit in this register has no effect. writing a one to a bit in this register will clear the corresponding bit in imr. 31 30 29 28 27 26 25 24 ???????? 23 22 21 20 19 18 17 16 ???????? 15 14 13 12 11 10 9 8 ???????? 76543210 ???????txrdy
910 42023e?sam?07/2013 atsam4l8/l4/l2 33.7.6 interrupt mask register name: imr access: read-only offset: 0x14 reset value: 0x00000000 0: the corresponding interrupt is disabled. 1: the corresponding interrupt is enabled. a bit in this register is cleared when the corresponding bit in idr is written to one. a bit in this register is set when the corresponding bit in ier is written to one. 31 30 29 28 27 26 25 24 ???????? 23 22 21 20 19 18 17 16 ???????? 15 14 13 12 11 10 9 8 ???????? 76543210 ???????txrdy
911 42023e?sam?07/2013 atsam4l8/l4/l2 33.7.7 interrupt status register name: isr access: read-only offset: 0x18 reset value: 0x00000000 ? txrdy: transmit ready 0 = dacc is not ready to accept new conversion requests. 1 = dacc is ready to accept new conversion requests. 31 30 29 28 27 26 25 24 ???????? 23 22 21 20 19 18 17 16 ???????? 15 14 13 12 11 10 9 8 ???????? 76543210 ???????txrdy
912 42023e?sam?07/2013 atsam4l8/l4/l2 33.7.8 write protect mode register name: wpmr access: read/write offset: 0xe4 reset value: 0x00000000 ? wpkey: write protect key this security code is needed to set/reset the wpen bit. must be filled with ?dac? ascii code ( 0x444143) . ? wpen: write protect enable 0 = disables the write protect. 1 = enables the write protect. 31 30 29 28 27 26 25 24 wpkey 23 22 21 20 19 18 17 16 wpkey 15 14 13 12 11 10 9 8 wpkey 76543210 ???????wpen
913 42023e?sam?07/2013 atsam4l8/l4/l2 33.7.9 write protect status register name: wpsr access: read-only offset: 0xe8 reset value: 0x00000000 ? wprotaddr: write protection error address address of the register write r equest which generated the error. ? wproterr: write protection error 0: no error. 1: write protection error. 31 30 29 28 27 26 25 24 ???????? 23 22 21 20 19 18 17 16 ???????? 15 14 13 12 11 10 9 8 wprotaddr 76543210 ???????wproterr
914 42023e?sam?07/2013 atsam4l8/l4/l2 33.7.10 version register name: version access: read-only offset: 0xfc reset value: - ? variant: variant number reserved. no functionality associated. ? version: version number reserved. no functionality associated. 31 30 29 28 27 26 25 24 ???????? 23 22 21 20 19 18 17 16 ????? variant 15 14 13 12 11 10 9 8 ???? version 76543210 version
915 42023e?sam?07/2013 atsam4l8/l4/l2 33.8 module configuration the specific configuration for each dacc instan ce is listed in the following tables.the module bus clocks listed here are connected to the system bus clocks. refer to section 10. ?power man- ager (pm)? on page 108 for details. table 33-3. abdacb clocks clock name description clk_dacc clock for the dacc bus interface table 33-4. register reset values register reset value version 0x00000111
916 42023e?sam?07/2013 atsam4l8/l4/l2 34. capacitive touch module (catb) rev: 1.0.0.0 34.1 features ? low-power capacitive proximity and touch detection ? touch filtering without cpu intervention ? capacitance measurement on multiple sensors for button/slider/wheel support ? autonomous interrupt generation on touch and out-of-touch events ? autocalibration prov ides automatic ad aptation to changing operating conditions ? peripheral-event-triggered acqui sition for autonomo us sleep operation and synchronization ? spread-spectrum operatio n for emi compatibility ? differential or single-ended sensing operation for measuremen t of both mutual and self capacitance ? support for internal and external discharge resistors 34.2 overview the capacitive touch module (catb) performs acquisition, filtering, and detection of capacitive touch sensors. the capacitive touch sensors use no mechanical components, and therefore demand less maintenance in the user applicati on. the catb can operate in different capaci- tance discharge modes: ? single-ended, with one pin per sensor ? differential, with two pins per sensor ? external discharge resistors, with an extra pin (dis) in single-ended mode ? internal discharge resistors using dma, the catb can sense on multiple s ensor pins. refer to the module configuration section for the number n of supported sensors. the catb can report measured capacitance val- ues to software algorithms for the implementat ion of buttons/sliders/wheels, and the user can configure thresholds triggering interrupts.
917 42023e?sam?07/2013 atsam4l8/l4/l2 34.3 block diagram figure 34-1. catb block diagram 34.4 i/o lines description 34.5 product dependencies in order to use the catb module, other parts of the system must be configured correctly, as described below. 34.5.1 i/o lines the catb pins may be multiplexed with the i/o controller lines. the user must first configure the i/o controller to assign the desired catb pins to their peripheral functions. 34.5.2 power management if the cpu enters a sleep mode th at disables clocks used by th e catb, it will stop functioning and the catb must be reinitialized to resume operation after the system wakes up from sleep mode. ongoing measurements will be invalid. t he catb can automatically request clocks when using the peripheral event system. the catb is able to wake the system from sleep mode using interrupts. 34.5.3 clocks the clock for the catb bus interface (clk_c atb) is generated by the power manager (pm). this clock is enabled at reset, and can be disabled in the pm. it is recommended to disable the catb before disabling this clock, in order to avoid freezing the catb in an undefined state. . . . capacitance counter filter threshold interface registers top spread repeat charget tidle tlevel idle raw thresh length pinsel cksel clk_acq rc oscillator gclk interrupt dis sensen sense0 peripheral bus dma control level clk_catb table 34-1. i/o lines description pin name pin description type sense[n:0] capacitive sense line input/output dis capacitive discharge line output
918 42023e?sam?07/2013 atsam4l8/l4/l2 the catb also depends on the acquisition clock (clk_acq). this clock can be configured to be either a dedicated generic clock (gclk), or a dedicated rc oscillator. the gclk must be enabled in the system control interface (scif) before the catb can be used. the rc oscillator is automatically enabled when needed. the rc osci llator and gclk used is specified in the module configuration section. 34.5.4 interrupts the catb interrupt request line is connected to the nvic. using the catb interrupt requires the nvic to be configured first. 34.5.5 direct memory access the catb can use dma to switch its configuration when sensing multiple sensors. two periph- eral dma channels must be configured: one for transferring configuration and state data into the catb, and one for storing the updated values back to ram. 34.5.6 debug operation when an external debugger forces the cpu into debug mode, the catb continues normal oper- ation. if the catb is configured in a way that requires it to be periodically serviced by the cpu through interrupts or similar, improper operation or data loss may result during debugging. care must be taken when accessing the dma register when the catb is in dma mode, as accessing this register can be misinterpreted as dma handshakes by the catb. 34.6 functional description 34.6.1 principle of operation the catb module detects touch by measuring change in sensor capacitance. the capacitance is measured by charging the sensor to a potential, and then timing the discharge through a resis- tor, yielding a measurement reflecting the curr ent rc value. the capacitance counter block in figure 34-1 and figure 34-2 performs the charge/discharge cycling, and reports measured val- ues to the filter. figure 34-2. catb signal filter as shown in figure 34-2 , the filter receives the measured values, subtracts a bias (the idle value), and filters away noise before using this as a correction value for the idle tracker. the fil- tered signal is further smoothed before yielding t he filtered level signal. the application can record an d process the ac quired level values in order to implement advanced touch-detection algorithms, or use the co nfigurable thresholds to generate interrupts. filter capacitance counter noise filter idle tracker idle - correction averaging filter measured raw level
919 42023e?sam?07/2013 atsam4l8/l4/l2 capacitive changes can correspond to touch, proximity, out-of-touch, or events such as change of power supply (ripple or ground shift). fast changing environmental parameters can also affect the touch measurements. while the catb can only measure and hold configuration and state for one sensor at the time, the peripheral dma controller can be used with a buffer in ram to rotate sensor configuration for the catb. 20 bytes of ram are then needed per sensor. figure 34-3. catb sensor connections. the catb can operate in single-ended or differential mode. in single-ended mode, one pin and one conductive area per sensor is required ( figure 34-3 a and b), selected in the pinsel regis- ter. when using external resistors in single-ended mode, a common discharge pin must be used ( figure 34-3 a). 34.6.2 basic operation before configuring the catb, the catb interface must be enabled by writing a one to the access enable bit in the control register (cr.en ). this enables writes to the catb registers. during the catb operation, the catb interface can be disabled by writing a zero to cr.en to save power and avoid accidental writes to the configuration registers. the catb is by default set up in single-ended m ode with external resistors. the default source for the acquisition clock is the dedicated rc oscillator. refer to the module configuration sec- toin for configuration of oscillators. the sample rate is selected by writing to the counter top value field in the count control regis- ter (cntcr.top) where for single-ended mode, is 2, and for differential mode, 4. note that cntcr.top must be writ- ten to a value such that the sample period is larger than the discharge time of the sensor, determined by the product of the sensor capacitance and the discharge resistance. before touch can be captured, the idle smoothing factor and relative level smoothing factor time durations in the filter timing register (timing.tidle and timing.tlevel) must be cho- sen to match the cntcr sample rate settings. timing.tidle and timing.tlevel are fractional positive values less than one and det ermine how many seconds the filters should sense k sense m dis sense k sense m a) b) sample rate 1 sample period ------------------------------------- f clk_acq top repeat ?? ------------------------------------------------ - ==
920 42023e?sam?07/2013 atsam4l8/l4/l2 average over. they should equal with typical t values being 5s for timi ng.tidle, and 0.1s for timing.tlevel. because the idle tracker is used to bias the measured values around zero, idle needs to be initialized with an appropriate value in order to avoid saturation of the filter. this value can either be obtained experimentally and stored in the application, or by writing a one to the initialize idle bit (cr.iidle) when the sensor is not touched, which causes idle to be loaded with the next measured value. cr.iidle is automatically cleared by hardware when this is done. the catb can perform acquisition on an array of selectable sense pins. the user selects pins in the pin select register (pinsel). sense[m] is selected by writing the value m to pinsel. to enable catb touch acquisition, the configurat ion registers should be loaded with application and sensor specific settings. writing a one to the start oper ation bit (cr.run) starts conversion and touch data is available when bits in the interr upt status register are set, optionally generat- ing interrupts. do not change settings during catb operation (cr.run is one). when an acquisition is done and a new sample is ready, the sample ready bit in the interrupt status register (isr.sample) is set. note that an overflow can occur if the catb sample rate is higher than the cpu?s capability to read the data. the catb will not report such overflows, and the user should check and verify the expected data rate with a timer. 34.6.3 differential mode the catb can be configured to work in differential mode, where sensing is done on two conduc- tive sensors. in this mode, both the mutual capacitance between the two sensors and the common capacitance is measured. in single-ended mode, only the common capacitance is measured. the differential mode is enabled by writing a one to the differential mode bit in the control reg- ister (cr.diff). in differential mode, two pins and two conductive areas per sensor are required ( figure 34-3 a and b). two pins will be used, sense[ m] and sense[m+1], selected by writing m to pinsel. figure 34-4. catb sensor connecti on, differential mode 34.6.4 thresholding in order for the catb to autonomously report t ouch, a threshold value must be written to the threshold register (thresh). the threshold value consists of an integer part 2 t sample rate 1 + ? ------------------------------------------------- sense m sense m+1 sense m sense m + 1 a) b)
921 42023e?sam?07/2013 atsam4l8/l4/l2 (thresh.rthresh), and a fractional part (t hresh.fthresh). the user should select a threshold value that corresponds to application typical sensor signal strengths. the threshold values are compared to the level register valu es, and the in touch bit in the interrupt status register (isr.intch) is set when the value in the level register is larger than the value in the thresh register, while the out of touch bi t (isr.outtch) is set when level becomes less than half of thresh, in effect creating a hysteres is between in- and out-of-touch events. during long touches, the value in the idle register will slowly increase and eventually cause a false out-of-touch event. when the touch is released, the measured value will become smaller than idle, causing a negative response on level. writing a one to the threshold direction bit in thresh (thresh.dir) enables negative thresholding, causing the catb to compare against -thresh. during negative thresholdi ng, isr.intch is set when level goes below the negative thresh value, and isr .outtch is set when level goes above the negative thresh/2 value. for better noise immunity, a threshold filter can be configured in the threshold length field in thresh (thresh.length). the threshold filter requires a number of samples to be over (or under, if negative thresholding is used) the threshold before the catb reports an in- or out-of- touch event. 34.6.5 acquisition clock and timing the discharge time of the capacitive sensor ov er the resistor is measured against clk_acq. the source for this clock is selected with the clock select bit in the control register (cr.cksel), and must remain unchanged during catb operation. the rc oscillator is avail- able on demand, and the gclk must be enabled before enabling the catb. refer to the module configuration section for the configuration of the generic clock and the rc oscillator. before each discharge measurement, the sensor is charged towards the i/o voltage or ground. writing to the charge time field in cr (cr.charget) selects the charge time duration, if larger charge times are needed, e.g. for large capacitive loads. if the measured discharge time is too small, the user can either increase the charge time by using a larger resistance value for the discharge resistor, or configure the catb to repeat and accumulate measurements by writing to the repeat measurements field in cntcr (cntcr.repeat). writing a non-zero value to cntcr.repeat will cause the acquisition block to repeat the acquisition repeat+1 times, summing the individual measurements before sending the sum to the filter block. 34.6.6 filter algorithm the filter in the catb consists of three main parts: a median3 filter, an idle tracker, and an aver- aging filter. the data in the catb is represented in a fixed-point format consisting of an integer part and a fractional part. not all of the lsb?s of the fractional bits might be implemented. refer to the module configuration section for the number of implemented fractional bits. the filter in the catb implements the following recurrence equations: raw n measured n idle n ? = median n median3 raw n 2 ? raw n 1 ? raw n ,, () = idle n 1 + idle n tidle median n ? + = level n 1 + level n tlevel median n level n ? () ? + =
922 42023e?sam?07/2013 atsam4l8/l4/l2 the and values can be observed in th e rawa and rawb fields respectively in the raw register. these values can be logged, and th e user can simulate the rest of the filter for tuning and debugging purposes. the idle tracker must be set up using timing.tidle to function as a slow-moving average to be subtracted from the measured values to remove the constant bias. this biases the signal around zero, with fast changes in capacitance shown as deviations from zero. the averaging filter, which outputs values to level, must be set up using timing.tlevel to have a faster response than the idle tracker, in order to function as a smoothing filter on the median-filtered signal. the thresholds are compared to the level value to decide whether or not a touch event should be generated. 34.6.7 multiple sensors and dma operation the catb can only hold state and configuration for one sensor at the time. in order to use the catb with multiple sensors, sensor data can be stored in ram using 5 x 32-bit words (20 bytes) per sensor (refer to table 34-2 ). the peripheral dma controller must be used to transfer state and configuration for the differ ent sensors back and forth between the catb and system mem- ory. dma mode of the catb is enabled by writ ing a one to the dma enable bit in the control register (cr.dmaen). when dma mode of the catb is enabled, the catb automatically gen- erates the required handshakes to the dma controller for transferring data back and forth with the correct timing. figure 34-5. transferring of configuration and state in multisensor mode as shown in figure 34-5 , configuration and state data is transferred between the system mem- ory and the catb using dma in the following sequence: 1. the configuration and state data for sensor 1 is read from memory and written to the catb 2. the dma read pointer is incremented, a nd the next read from memory will read the data for sensor 2 3. the catb performs an acquisition using the parameters for sensor 1 raw n raw n 1 ? stored state for sensor 1 catb working state stored state for sensor 2 dma read pointer dma write pointer peripheral dma controller 0 19 20 39 1 2 3 4 5 system ram:
923 42023e?sam?07/2013 atsam4l8/l4/l2 4. the updated data is written back to memory, overwriting the previous configuration and state 5. the dma write pointer is incremented, and the next write to memory will write the data for sensor 2 using the ring buffer fe ature of the dma controlle r, the system will go cyclically through the sen- sors set up in memory. detected touch events for different sensor configur ations are reported in the in-touch status bits in the in-touch registers (intchn.intchm), and in the out-of-touch status bits in the out-of- touch registers (outtchn.outtchm). when bits in these registers are set, the isr.intch or isr.outtch bits are also set. the switched data contains the following: ? timing information (as described in the timing register) ? current idle and level values ? threshold configuration (as described in the thresh register) ? current touch state (tchstate); zero being out-of touch, selecting thresh for monitoring, and one being in-touch, selecting thresh/2 for monitoring ? status bit select (statu ssel), selecting intchn.int chm, and outtchn.outtchm ? internal states for the dsp (should be initialized to zero); length count (length_count), counting samples beyond thresholds, and comparator state (cmpstate), a filter cache table 34-2. layout of data in memory for one sensor configuration byte/bit7 6543210 0 - length_count[4:3] thresh.length[4:0] 1 thresh.dir length_count[2:0] thresh.rthresh[7:4] 2 thresh.rthresh[3:0] t hresh.fthresh[11:8] 3 thresh.fthresh[7:0] 4 - - - - idle.ridle[15:12] 5 idle.ridle[11:4] 6 idle.ridle[3:0] idle.fidle[11:8] 7 idle.fidle[7:0] 8 - ------- 9 - - - - level.rlevel[7:4] 10 level.rlevel[3:0] l evel.flevel[11:8] 11 level.flevel[7:0] 12 cmpstate tchstate - - timing.tidle[11:8] 13 timing.tidle[7:0] 14 - - - - timing.t level[11:8] 15 timing.tlevel[7:0] 16 raw.rawb[7:0] 17 raw.rawa[7:0] 18 statussel[7:0] 19 pinsel.pinsel[7:0]
924 42023e?sam?07/2013 atsam4l8/l4/l2 ? length_count: number of samples over threshold ? this value is used to track how many samples that have crossed the threshold (thresh.rthresh and thresh.fthresh), and is compared to thresh.length. this field sh ould be initialized to zero. ? thresh.length: threshold length ? thresh.dir: threshold direction ? thresh.rthresh: threshold, integer part ? thresh.fthresh: threshold, fractional part ? refer to corresponding fields in section 34.7.7 ?threshold register? on page 935 . ? idle.ridle: sensor idle value, integer part ? idle.fidle: sensor idle value, fractional part ? refer to corresponding fields in section 34.7.3 ?sensor idle level? on page 931 . ? level.rlevel: sensor relative level, integer part ? level.flevel: sensor relative level, fractional part ? refer to corresponding fields in section 34.7.4 ?sensor relative level? on page 932 ? cmpstate: comparator state ? internal state used by noise filter. this field should be in itialized to zero. ? tchstate: touch state ? state bit used for hysteresis. 0: the sensor is out of touch. 1: the sensor is in touch ? timing.tidle: timing constant for the idle value ? timing.tlevel: timing constant for the relative level ? refer to corresponding fields in section 34.7.6 ?filter timing register? on page 934 . ? raw.rawb: sensor raw value b ? raw.rawa: sensor raw value a ? refer to corresponding fields in section 34.7.5 ?sensor raw value? on page 933 . ? statussel: selection of status bit ? the catb only has one common interrupt for in- and out-of-touch events respectively. to assist the software to quickly determine which sensor caused a interrupt, additional bits in the in- and out-of-touch status registers (intch and outtch) can be updated. the value in this field select which bit that should be updated. refer to the module configuration section for details on how many such bits that are implemented. ? pinsel.pinsel: pin selection ? refer to corresponding field in section 34.7.8 ?pin selection register? on page 936 . to enable dma transfers, the user needs to setup the following: 1. write the individual sensor configurations into an array in ram, according to the layout in table 34-2 . 2. enable the peripheral dma controller in circular mode, pointing it to the ram array. two channels are needed: one for writing to the catb, and one for reading from the catb.
925 42023e?sam?07/2013 atsam4l8/l4/l2 3. configure common setup for all sensors (such as cntcr.top, cntcr.charget, cntcr.spread). 4. write a one to the dma enable (cr.dmaen) and the cr.run bit. having a separate statussel and pinsel allows the user to set up e.g. multiple thresholds on the same pin. this can be used for having multi- level threshold (proximity and touch), or for having different signs for the threshold, to capture both decrease and increase in capacitance on the same sensor. 34.6.8 spread-spectrum operation in order to reduce electromagnetic interference (emi), a spread-spectrum mode of operation can be accomplished by adding jitter to the sampling frequency. the spread-spectrum operation also reduces the probability of periodic interference on the measurements. figure 34-6. counter in spread-spectrum operation writing a non-zero deviation value to the spread spectrum field (cntcr.spread) will cause the effective top value to alternate in a sawtooth pattern, with 16 different values ranging from to top. figure 34-6 shows in principle how the catb would vary the period if the spread spectrum generator varied between 4 different values instead of 16. 34.6.9 interrupts the catb has three interrupt sources: ? sample - sample ready ? new measurement sample ready since last write to icr.sample. ? intch - in-touch ? in-touch event detected ? outtch - out-of-touch ? out-of-touch event detected each interrupt source has a corresponding bit in the interrupt status register (isr). an interrupt request will be generated if the bit in the interrupt status register and the corre- sponding bit in the interrupt mask register (imr) are set. the interrupt sources are ored together to form one interrupt request. the catb will generate an interrupt request if at least one of the corresponding bits in imr is set. bits in imr are set by writing a one to the corre- sponding bit in the interrupt enable register (ier), and cleared by writing a one to the corresponding bit in the interrupt disable regist er (idr). the interrupt request remains active until the corresponding bit in isr is cleared by writing a one to the corresponding bit in the sta- tus clear register (scr). because all the interrupt sources are ored together, the interrupt request from the catb will remain active until all the bits in isr are cleared. 34.6.10 peripheral even t triggered operation during normal operation, the catb performs sens or sampling continuously. in the peripheral- event-triggered mode of operation, the catb ca n receive periodic peripheral events, which trig- top: 0: top 16 2 spread 1 ? ? () ?
926 42023e?sam?07/2013 atsam4l8/l4/l2 ger one acquisition per event. the peripheral-event-triggered operation is enabled by writing a one to the event triggered operation bit in the c ontrol register (cr.etrig). in this mode, the catb will start the required clocks for performing an ac quisition, and can thereby op erate in all sleep modes where the peripheral event generator is running. using the peripheral-event-triggered mode allows the catb to be used as a low-power wake-up source for the cpu, as interrupts can be generated on in-touch or out-of-touch events. it is not possible to use multiple sensors in sleep modes where the peripheral dma controller is disabled. writing a one to the event triggered operation bit in the control register (cr.etrig) will dis- able the continuous sampling and only sample when the catb receives a peripheral event. the number of samples per peripheral event can be configured by writing to the number of event samples field in the control register (cr.esamples). one peripheral event causes cr.esa- mples+1 samples to be acquired. if a monitored threshold is passed, t he catb can wake the device from sleep. when the catb receives a peripheral event during sleep mode, it automatically requests both the clk_catb and the clk_acq clock. note that it is not possible to use the peripheral-event- triggered operation with the gclk as a source for clk_acq in sleep modes where the gclk is disabled. refer to section 10. ?power manager (pm)? on page 108 for details. if no touch is detected after an acquisition, clk_catb and clk_acq will be stopped, returning the device to low power mode.
927 42023e?sam?07/2013 atsam4l8/l4/l2 34.7 user interface note: 1. the reset values are device specific. refer to the module configuration section at the end of this chapter. table 34-3. catb register memory map offset register register name access reset 0x00 control register cr read/write 0x00000000 0x04 counter control register cntcr read/write 0x00000000 0x08 sensor idle level idle read/write 0x00000000 0x0c sensor relative level level read-only 0x00000000 0x10 sensor raw value raw read-only 0x00000000 0x14 filter timing register timing read/write 0x00000000 0x18 threshold register thresh read/write 0x00000000 0x1c pin selection register pinsel read/write 0x00000000 0x20 direct memory access register dma read/write 0x00000000 0x24 interrupt status register isr read-only 0x00000000 0x28 interrupt enable register ier write-only 0x00000000 0x2c interrupt disable register idr write-only 0x00000000 0x30 interrupt mask register imr read-only 0x00000000 0x34 status clear register scr write-only 0x00000000 0x40+4n in-touch status regist er n intchn read-only 0x00000000 0x50+4n in-touch status clear register n intchclrn write-only 0x00000000 0x60+4n out-of-touch status register n outtchn read-only 0x00000000 0x70+4n out-of-touch status clear regi ster n outtchclrn write-only 0x00000000 0xf8 parameter register parameter read-only - (1) 0xfc version register version read-only - (1)
928 42023e?sam?07/2013 atsam4l8/l4/l2 34.7.1 control register name: cr access type: read/write offset: 0x00 reset value: 0x00000000 ? swrst: software reset writing a zero to this bit has no effect. writing a one to this bit resets the catb. the catb will be disabled after the reset. this bit always reads as zero. ? charget: charge time the measured capacitance is charged fo r 2^(charget) clock cycles of the acquis ition clock (selected with cksel) before each discharge measurement. this field must not be changed when the catb is operating (cr.run is one). ? esamples: number of event samples when the catb is driven by the peripheral event syst em, the amount of samples per event equal esamples +1. ? dmaen: dma enable 0: dma is not used. single sensor mode of operation. 1: dma is being used for multi sensor operation. sens or configuration data is rotated with data from ram. ? diff: differential mode 0: normal acquisition mode. one pin is used per sensor (plus the shared discharge pin (dis) if intres is zero. 1: differential mode. two pins are used per sensor. note: this bit must not be changed during operation (run is one). ? cksel: clock select 0: the rc oscillator is selected as acquisition cloc k and is used as timing sour ce for the measurements. 1: the gclk is selected as acquisition clock and is used as the timing source for measurements. refer to the module configuration se ction for configuration of clocks. note: this bit must not be changed during operation (run is one). ? intres: internal resistors 0: external resistors are used between dis an d sense pins, or between sensor-pads if diff=1. 1: internal resistors are used. note: this bit must not be changed during operation (run=1). 31 30 29 28 27 26 25 24 swrst------- 23 22 21 20 19 18 17 16 ---- charget 15 14 13 12 11 10 9 8 - esamples 76543210 dmaen diff cksel intres etrig iidle run en
929 42023e?sam?07/2013 atsam4l8/l4/l2 ? etrig: event triggered operation 0: normal continuous acquisition mode of operation. 1: catb acquisitions are triggered by the peripheral event system. ? iidle: initialize idle value 0: the idle register will only be updat ed by the catb, or if written to. 1: the idle register is set to the next measured value. this bit always reads as zero. ? run: start operation writing a zero to this bit will stop the catb. writing a one to this bit will usually start acquisitions immedi ately. if cr.dmaen is one, the catb will wait until the first d ma transfer. if cr.etrig is one, the catb will wait for a peripheral event. 0: catb is stopped. 1: catb is running. ? en: access enable 0: the catb interface is disabled, register configuration settings can not be changed. 1: the catb interface is enabled, register configuration settings can be changed.
930 42023e?sam?07/2013 atsam4l8/l4/l2 34.7.2 counter control register name: cntcr access type: read/write offset: 0x04 reset value: 0x00000000 note: this register must not be written to during catb operation (cr.run is one). ? repeat: repeat measurements measurements are repeated repe at+1 times in the acqusition block. the i ndividual measurements are summed before being sent to the filter. ? spread: spread spectrum 0: normal mode of operation. spread sp ectrum mode of operation is not used. 1-15: spread-spectrum mode of operation. th e effective top value deviation ranges from to top . ? top: counter top value determines sample rate. 31 30 29 28 27 26 25 24 - repeat spread 23 22 21 20 19 18 17 16 top[23:16] 15 14 13 12 11 10 9 8 top[15:8] 76543210 top[7:0] top 16 2 spread 1 ? ? () ?
931 42023e?sam?07/2013 atsam4l8/l4/l2 34.7.3 sensor idle level name: idle access type: read/write offset: 0x08 reset value: 0x00000000 this register value is subtracted from in itial measurement data in order to determine the relative capacitance. the idle value is updated as a moving exponential weighted average of previous m easurements, with the time-constant given in timing.tidle. this register value is updated when isr.sample is set. ? ridle: integer sensor idle this field contains the integer part of the measured idle-signal value. ? fidle: fractional sensor idle this field contains the fractional part of the measured idle-signa l value. note that some of the lsb?s of the fractional part m ight not be implemented. refer to th e module configuration section. 31 30 29 28 27 26 25 24 - - - - ridle[15:12] 23 22 21 20 19 18 17 16 ridle[11:4] 15 14 13 12 11 10 9 8 ridle[3:0] fidle[11:8] 76543210 fidle[7:0]
932 42023e?sam?07/2013 atsam4l8/l4/l2 34.7.4 sensor relative level name: level access type: read-only offset: 0x0c reset value: 0x00000000 this register contains the latest sensor measurement value. it has been filtered, subt racted from the idle register values, and smoothened. this value is compared to the th resh register values to determine whether the sensor is in touch or not. filter smoothening is determined by the timing.tlevel value. when th is register is updated, isr.sample is set by the catb. ? rlevel: integer sensor level this field contains the integer part of the measured sensor discharge value. ? flevel: fractional sensor level this field contains the fractional part of the measured sensor discharge value. note t hat some of the lsb?s of the fractional p art might not be implemented. refer to the module configuration section. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 - - - - rlevel[7:4] 15 14 13 12 11 10 9 8 rlevel[3:0] flevel[11:8] 76543210 flevel[7:0]
933 42023e?sam?07/2013 atsam4l8/l4/l2 34.7.5 sensor raw value name: raw access type: read-only offset: 0x10 reset value: 0x00000000 ? rawb: last sensor raw value the unfiltered counter valu e from last acquisition. ? rawa: current sensor raw value the unfiltered counter value from last acquisition, with idle subtracted. 31 30 29 28 27 26 25 24 rawb 23 22 21 20 19 18 17 16 rawa 15 14 13 12 11 10 9 8 -------- 76543210
934 42023e?sam?07/2013 atsam4l8/l4/l2 34.7.6 filter timing register name: timing access type: read/write offset: 0x14 reset value: 0x00000000 ? tidle: idle smoothening this field determines how fast idle tracker should track the measur ed samples. note that some of the lsb?s of this field might not be implemented. refer to th e module configuration section. ? tlevel: relative level smoothening the field determines the smoothening factor to the averaging filt er. note that some of the lsb?s of this field might not be implemented. refer to the mo dule configuration section. 31 30 29 28 27 26 25 24 ---- tidle[11:8] 23 22 21 20 19 18 17 16 tidle[7:0] 15 14 13 12 11 10 9 8 - - - - tlevel[11:8] 76543210 tlevel[7:0]
935 42023e?sam?07/2013 atsam4l8/l4/l2 34.7.7 threshold register name: thresh access type: read/write offset: 0x18 reset value: 0x00000000 ? length: threshold length the amount of successive samples that have to be beyond t he threshold before a in- or out-of-touch event is detected. ? dir: threshold direction 0: touch is detected when l evel goes above threshold value. 1: touch is detected when l evel goes below threshold value. ? rthresh: integer threshold value the integer part of the threshold value. note that some of the lsb?s of this field might not be implemented. refer to the modul e configuration section. ? fthresh: fractional threshold value the fractional part of the threshold value. note that some of th e lsb?s of this field might not be implemented. refer to the module configuration section. 31 30 29 28 27 26 25 24 --- length 23 22 21 20 19 18 17 16 dir - - - rthresh[7:4] 15 14 13 12 11 10 9 8 rthresh[3:0] fthresh[11:8] 76543210 fthresh[7:0]
936 42023e?sam?07/2013 atsam4l8/l4/l2 34.7.8 pin selection register name: pinsel access type: read/write offset: 0x1c reset value: 0x00000000 the number of available bits in this register is device de pendent. refer to the module configuration section for details. ? pinsel: pin select the pin selected for touch acquisition. in differential mode (cr.diff is one), two pins are selected when writing m to pinsel: sense[m] and sense[m+1]. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------- 76543210 pinsel
937 42023e?sam?07/2013 atsam4l8/l4/l2 34.7.9 direct memory access register name: dma access type: read/write offset: 0x20 reset value: 0x00000000 note: this register is used for dma transfers between the catb and ram. this register must not be read or written by the user. 31 30 29 28 27 26 25 24 dma[31:24] 23 22 21 20 19 18 17 16 dma[23:16] 15 14 13 12 11 10 9 8 dma[15:8] 76543210 dma[7:0]
938 42023e?sam?07/2013 atsam4l8/l4/l2 34.7.10 interrupt status register name: isr access type: read-only offset: 0x24 reset value: 0x00000000 bits in this register are cleared by writing a one to th e corresponding bit in the st atus clear register (scr). ? outtch: out-of-touch 0: no out-of-touch event detected. 1: out-of-touch event detected. ? intch: in-touch 0: no in-touch event detected. 1: in-touch event detected. ? sample: sample ready 0: no new measurement sample ready since last write to idr.sample. 1: new measurement sample ready since la st write to scr.sample. the values in the level, raw, and idle registers have been updated. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------- 76543210 - - - - - outtch intch sample
939 42023e?sam?07/2013 atsam4l8/l4/l2 34.7.11 interrupt enable register name: ier access type: write-only offset: 0x28 reset value: 0x00000000 writing a zero to a bit in this register has no effect. writing a one to a bit in this register will set the corresponding bit in imr. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------- 76543210 - - - - - outtch intch sample
940 42023e?sam?07/2013 atsam4l8/l4/l2 34.7.12 interrupt disable register name: idr access type: write-only offset: 0x2c reset value: 0x00000000 writing a zero to a bit in this register has no effect. writing a one to a bit in this register will clear the corresponding bit in imr. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------- 76543210 - - - - - outtch intch sample
941 42023e?sam?07/2013 atsam4l8/l4/l2 34.7.13 interrupt mask register name: imr access type: read-only offset: 0x30 reset value: 0x00000000 0: the corresponding interrupt is disabled. 1: the corresponding interrupt is enabled. a bit in this register is cleared when the corresponding bit in idr is written to one. a bit in this register is set when the corresponding bit in ier is written to one. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------- 76543210 - - - - - outtch intch sample
942 42023e?sam?07/2013 atsam4l8/l4/l2 34.7.14 status clear register name: scr access type: write-only offset: 0x34 reset value: 0x00000000 writing a zero to a bit in this register has no effect. writing a one to a bit in this register will clear the corresponding bit in isr and the corresponding interrupt request. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------- 76543210 - - - - - outtch intch sample
943 42023e?sam?07/2013 atsam4l8/l4/l2 34.7.15 in-touch status register i name: intchi access type: read-only offset: 0x40+4i reset value: 0x00000000 ? intchj: in-touch these bits provides status when the catb operates in dma mode. each block of configuration data (see table 34-2 ), can choose in the statussel field which bit in this register that should be set when an in-touch event is detected. a statussel value of 0 will choose the intch0 bit in the intch0 register (i ==0 and j==0), while a statussel of 42 will choose the inttch10 bit in the intch1 register (i ==1 and j==10). refer to the module configuration section for details of the number of bits implemented in theese registers. 0: dma configuration with stat ussel set to i*32+j has not registered an in-touch event. 1: dma configuration with st atussel set to i*32+j has registered an in-touch event. 31 30 29 28 27 26 25 24 intch31 intch30 intch29 intch28 i ntch27 intch26 intch25 intch24 23 22 21 20 19 18 17 16 intch23 intch22 intch21 intch20 i ntch19 intch18 intch17 intch16 15 14 13 12 11 10 9 8 intch15 intch14 intch13 intch12 i ntch11 intch10 intch9 intch8 76543210 intch7 intch6 intch5 intch4 intch3 intch2 intch1 intch0
944 42023e?sam?07/2013 atsam4l8/l4/l2 34.7.16 in-touch status clear register n name: intchclrn access type: write-only offset: 0x50+4n reset value: 0x00000000 ? intchclrm: in-touch clear writing a one to a bit in this register will clear the corresponding bit in intchn.intchm. 31 30 29 28 27 26 25 24 intchclr31 intchclr30 intchclr29 intchclr28 intchclr27 intchclr26 intchclr25 intchclr24 23 22 21 20 19 18 17 16 intchclr23 intchclr22 intchclr21 intchclr20 intchclr19 intchclr18 intchclr17 intchclr16 15 14 13 12 11 10 9 8 intchclr15 intchclr14 intchclr13 intchclr12 intchclr11 intchclr10 intchclr9 intchclr8 76543210 intchclr7 intchclr6 intchclr5 intchclr4 intchclr3 intchclr2 intchclr1 intchclr0
945 42023e?sam?07/2013 atsam4l8/l4/l2 34.7.17 out-of-touch status register i name: outtchi access type: read-only offset: 0x60+4i reset value: 0x00000000 ? outtchj: out-of-touch these bits provides status when the catb operates in dma mode. each block of configuration data (see table 34-2 ), can choose in the statussel field which bit in this register that should be set when an out- of-touch event is detected. a statussel value of 0 will choose the outtch0 bit in the outtch0 register (i ==0 and j==0), while a statussel of 42 will choose the outtch10 bit in the outtch1 register (i ==1 and j= =10). refer to the module configuration section for details of the number of bits implem ented in theese registers. 0: dma configuration with statu ssel set to i*32+j has not r egistered an out-of-touch event. 1: dma configuration with stat ussel set to i*32+j has re gistered an out-of-touch event. 31 30 29 28 27 26 25 24 outtch31 outtch30 outtch29 outtch28 o uttch27 outtch26 outtch25 outtch24 23 22 21 20 19 18 17 16 outtch23 outtch22 outtch21 outtch20 o uttch19 outtch18 outtch17 outtch16 15 14 13 12 11 10 9 8 outtch15 outtch14 outtch13 outtch1 2 outtch11 outtch10 outtch9 outtch8 76543210 outtch7 outtch6 outtch5 outtch4 outtch3 outtch2 outtch1 outtch0
946 42023e?sam?07/2013 atsam4l8/l4/l2 34.7.18 out of touch status clear register n name: outtchclrn access type: write-only offset: 0x70+4n reset value: 0x00000000 ? outtchclrm: out of touch writing a one to a bit in this register will clear the corresponding bit in outtchn.outtchm. 31 30 29 28 27 26 25 24 outtchclr31 outtchclr30 outtchclr29 outtchclr28 outtchclr27 outtchclr26 outtchclr25 outtchclr24 23 22 21 20 19 18 17 16 outtchclr23 outtchclr22 outtchclr21 outtchclr20 outtchclr19 outtchclr18 outtchclr17 outtchclr16 15 14 13 12 11 10 9 8 outtchclr15 outtchclr14 outtchclr13 outtchclr12 outtchclr11 outtchclr10 outtchclr9 outtchclr8 76543210 outtchclr7 outtchclr6 outtchclr5 outtchclr4 outtchclr3 outtchclr2 outtchclr1 outtchclr0
947 42023e?sam?07/2013 atsam4l8/l4/l2 34.7.19 parameter register name: parameter access type: read-only offset: 0xf8 reset value: - ? fractional: number of fractional bits the number of implemented fractional bits. ? nstatus: number of status bits the number of implemented status bits. ? npins: number of pins the number of connected pins. 31 30 29 28 27 26 25 24 ------- 23 22 21 20 19 18 17 16 ---- fractional 15 14 13 12 11 10 9 8 nstatus 76543210 npins
948 42023e?sam?07/2013 atsam4l8/l4/l2 34.7.20 version register name: version access type: read-only offset: 0xfc reset value: - ? variant: variant number reserved. no functionality associated. ? version: version number version number of the module. no functionality associated. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 ---- variant 15 14 13 12 11 10 9 8 - - - - version[11:8] 76543210 version[7:0]
949 42023e?sam?07/2013 atsam4l8/l4/l2 34.8 module configuration the specific configuration for each catb instanc e is listed in the following tables.the module bus clocks listed here are connected to the system bus clocks. refer to section 10. ?power man- ager (pm)? on page 108 for details. table 34-4. catb configuration feature catb number of sensors/connected pins 32 number of status bits in statussel 32 number of fractional bits implemented in idle, level, timing, and thresh. 10 number of available bits in the pinsel register 5 table 34-5. catb clocks clock name description clk_catb clock for the catb bus interface rc oscillator source clock for the clk_acq gclk source clock for the clk_acq. the generic clock used for the catb is gclk3 table 34-6. register reset values register reset value version 0x00000100 parameter 0x000a2020
950 42023e?sam?07/2013 atsam4l8/l4/l2 35. true random number generator (trng) rev: 1.0.3.0 35.1 features ? passed nist special publi cation 800-22 tests suite ? passed diehard random tests suite ? provides a 32-bit random number every 84 clock cycles 35.2 overview the true random number generator provides 32-bit random numbers. 35.3 functional description the true random number generator (trng) passes the american nist special publication 800-22 and diehard random tests suites. as soon as the trng is enabled (writing the enable bit in the cr register with the correct key), the generator provides one 32-bit value every 84 clock cycles. an interrupt can be enabled through the ier register (respectively disabled in idr). this interrupt is set when a new random value is available and is cleared when the interrupt status register is read (isr). the bit datrdy in isr is set when the random data is ready to be read out on the 32-bit output data register (odata). the user should check that the datrdy bit is one before readin the odata register when a 32- bit random value is required. figure 35-1. trng data generation sequence 84 clock cycles 84 clock cycles 84 clock cycles read trng_isr read trng_odata read trng_isr read trng_odata clock trng_int trng_cr enable
951 42023e?sam?07/2013 atsam4l8/l4/l2 35.4 user interface notes: 1. values in the version register vary with the version of the ip block implementation. table 35-1. trng register memory map offset register name access reset 0x00 control register cr write-only ? 0x10 interrupt enable register ier write-only ? 0x14 interrupt disable register idr write-only ? 0x18 interrupt mask register imr read-only 0x0000_0000 0x1c interrupt status register isr read-only 0x0000_0000 0x50 output data register odata read-only 0x0000_0000 0xfc version register version read-only ? (1)
952 42023e?sam?07/2013 atsam4l8/l4/l2 35.4.1 control register name: cr access type: write-only offset: 0x00 reset value: ? ? key: security key key = 0x524e47 (rng in ascii) this field must be written to 0x524e47 for a write operation to be effective. ? enable: enables the trng to provide random values writing a zero to this bit disables the trng. writing a one to this bit enables the trng. 31 30 29 28 27 26 25 24 key 23 22 21 20 19 18 17 16 key 15 14 13 12 11 10 9 8 key 76543210 ???????enable
953 42023e?sam?07/2013 atsam4l8/l4/l2 35.4.2 interrupt enable register name: ier access type: write-only offset: 0x10 reset value: ? writing a zero to a bit in this register has no effect. writing a one to a bit in this register will set the corresponding bit in imr 31 30 29 28 27 26 25 24 ???????? 23 22 21 20 19 18 17 16 ???????? 15 14 13 12 11 10 9 8 ???????? 76543210 ???????datrdy
954 42023e?sam?07/2013 atsam4l8/l4/l2 35.4.3 interrupt disable register name: idr access type: write-only offset: 0x14 reset value: ? writing a zero to a bit in this register has no effect. writing a one to a bit in this register will clear the corresponding bit in imr 31 30 29 28 27 26 25 24 ???????? 23 22 21 20 19 18 17 16 ???????? 15 14 13 12 11 10 9 8 ???????? 76543210 ???????datrdy
955 42023e?sam?07/2013 atsam4l8/l4/l2 35.4.4 interrupt mask register name: imr access type: read-only offset: 0x18 reset value: 0x00000000 0: the corresponding interrupt is disabled. 1: the corresponding interrupt is enabled. this bit is cleared when the corresponding bit in idr is written to one. this bit is set when the corresponding bit in ier is written to one. 31 30 29 28 27 26 25 24 ???????? 23 22 21 20 19 18 17 16 ???????? 15 14 13 12 11 10 9 8 ???????? 76543210 ???????datrdy
956 42023e?sam?07/2013 atsam4l8/l4/l2 35.4.5 interrupt status register name: isr access type: read-only offset: 0x34 reset value: 0x00000000 ? datrdy: data ready 0 = output data is not valid or trng is disabled. 1 = new random value is completed. datrdy is cleared when this register is read. 31 30 29 28 27 26 25 24 ???????? 23 22 21 20 19 18 17 16 ???????? 15 14 13 12 11 10 9 8 ?????? 76543210 ???????datrdy
957 42023e?sam?07/2013 atsam4l8/l4/l2 35.4.6 output data register name: odata access type: read-only offset: 0x34 reset value: 0x00000000 ? odata: output data the 32-bit output data register contains the 32-bit random data. 31 30 29 28 27 26 25 24 odata 23 22 21 20 19 18 17 16 odata 15 14 13 12 11 10 9 8 odata 76543210 odata
958 42023e?sam?07/2013 atsam4l8/l4/l2 35.4.7 version register name: version access type: read-only offset: 0xfc reset value: - ? variant: variant number reserved. no functionality associated. ? version: version number version number of the module. no functionality associated. 31 30 29 28 27 26 25 24 ???????? 23 22 21 20 19 18 17 16 ????? variant 15 14 13 12 11 10 9 8 ???? version 76543210 version
959 42023e?sam?07/2013 atsam4l8/l4/l2 35.5 module configuration the specific configuration for each trng instance is listed in the following tables.the module bus clocks listed here are connected to the system bus clocks. refer to section 10. ?power man- ager (pm)? on page 108 for details. table 35-2. trng clock name module name clock name description trng clk_trng peripheral clock for trng table 35-3. register reset values register reset value version 0x00000103
960 42023e?sam?07/2013 atsam4l8/l4/l2 36. glue logic controller (gloc) rev: 1.0.2.0 36.1 features ? glue logic for general purpose pcb design ? programmable lookup table ? up to four inputs supported per lookup table ? optional filtering of output 36.2 overview the glue logic controller (gloc) contains programmable logic which can be connected to the device pins. this allows the user to eliminate logic gates for simple glue logic functions on the pcb. the gloc consists of a number of lookup tabl e (lut) units. each lut can generate an output as a user programmable logic expression with fo ur inputs. inputs can be individually masked. the output can be combinatorially generated from the inputs, or filtered to remove spikes. 36.3 block diagram figure 36-1. gloc block diagram peripheral bus truth filter out[0] ... out[n] filten in[3:0] ? in[(4n+3):4n] aen clk_gloc gclk
961 42023e?sam?07/2013 atsam4l8/l4/l2 36.4 i/o lines description each lut have 4 inputs and one output. the inputs and outputs for the luts are mapped sequentially to the inputs and outputs. this means that lut0 is connected to in0 to in3 and out0. lut1 is connected to in4 to in7 and out1. in general, lutn is connected to in[4n] to in[4n+3] and outn. 36.5 product dependencies in order to use this module, other parts of the system must be configured correctly, as described below. 36.5.1 i/o lines the pins used for interfacing the gloc may be multiplexed with i/o controller lines. the pro- grammer must first program the i/o controller to assign the desired gloc pins to their peripheral function. if i/o lines of the gloc are no t used by the application, they can be used for other purposes by the i/o controller. it is only required to enable the gloc inputs and outputs in use. pullups for pins configured to be used by the gloc will be disabled. 36.5.2 clocks the clock for the gloc bus interface (clk_gloc) is generated by the power manager. this clock is disabled at reset, and can be enabled in the power manager. it is recommended to dis- able the gloc before disabling the clock, to avoid freezing the module in an undefined state. additionally, the gloc depends on a dedicated generic clock (gclk). the gclk can be set to a wide range of frequencies and clock sources, and must be enabled by the system control interface (scif) before the gloc filter can be used. 36.5.3 debug operation when an external debugger forces the cpu into debug mode, the gloc continues normal operation. 36.6 functional description 36.6.1 enabling the lookup table inputs since the inputs to each lookup table (lut) unit can be multiplexed with other peripherals, each input must be explicitly enabled by writing a one to the corresponding enable bit (aen) in the corresponding contro l register (cr). if no inputs are enabled, the output outn will be the least signif icant bit in the truthn register. table 36-1. i/o lines description pin name pin description type in0-inm inputs to lookup tables input out0-outn output from lookup tables output
962 42023e?sam?07/2013 atsam4l8/l4/l2 36.6.2 configuring the lookup table the lookup table in each lut unit can generate any logic expression out as a function of up to four inputs, in[3:0]. the truth table for the expression is written to the truth register for the lut. table 36-2 shows the truth table for lut0. the truth table for lutn is written to truthn, and the corresponding input and outputs will be in[4n] to in[4n+3] and outn. 36.6.3 output filter by default, the output outn is a combinatorial func tion of the inputs in[4n] to in[4n+3]. this may cause some short glitches to occur when the inputs change value. it is also possible to clock the output through a fi lter to remove glitches. this requires that the corresponding generic clock (gclk) has been enabled before use. the filter can then be enabled by writing a one to the filter enable (filten) bit in crn. the outn output will be delayed by three to four gclk cycles when the filter is enabled. table 36-2. truth table for the lookup table in lut0 in[3] in[2] in[1] in[0] out[0] 0 0 0 0 truth0[0] 0 0 0 1 truth0[1] 0 0 1 0 truth0[2] 0 0 1 1 truth0[3] 0 1 0 0 truth0[4] 0 1 0 1 truth0[5] 0 1 1 0 truth0[6] 0 1 1 1 truth0[7] 1 0 0 0 truth0[8] 1 0 0 1 truth0[9] 1 0 1 0 truth0[10] 1 0 1 1 truth0[11] 1 1 0 0 truth0[12] 1 1 0 1 truth0[13] 1 1 1 0 truth0[14] 1 1 1 1 truth0[15]
963 42023e?sam?07/2013 atsam4l8/l4/l2 36.7 user interface note: 1. the reset values are device specific. refer to the module configuration section at the end of this chapter. table 36-3. gloc register memory map offset register register name access reset 0x00+n*0x08 control register n crn read/write 0x00000000 0x04+n*0x08 truth table register n truthn read/write 0x00000000 0x38 parameter register parameter read-only - (1) 0x3c version register version read-only - (1)
964 42023e?sam?07/2013 atsam4l8/l4/l2 36.7.1 control register n name: crn access type: read/write offset : 0x00+n*0x08 reset value: 0x00000000 ? filten: filter enable 1: the output is glitch filtered. 0: the output is not glitch filtered. ? aen: enable in inputs input in[n] is enabled when aen[n] is one. input in[n] is disabled when aen[n] is zero, and will not affect the out value. 31 30 29 28 27 26 25 24 filten------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------- 76543210 ---- aen
965 42023e?sam?07/2013 atsam4l8/l4/l2 36.7.2 truth table register n name: truthn access type: read/write offset : 0x04+n*0x08 reset value: 0x00000000 ? truth: truth table value this value defines the output ou t as a function of inputs in: out = truth[in] 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 truth[15:8] 76543210 truth[7:0]
966 42023e?sam?07/2013 atsam4l8/l4/l2 36.7.3 parameter register name: parameter access type: read-only offset :0x38 reset value: - ? luts: lookup table units implemented this field contains the number of lookup table units implemented in this device. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------- 76543210 luts
967 42023e?sam?07/2013 atsam4l8/l4/l2 36.7.4 version register name: version access type: read-only offset :0x3c reset value: - ? variant: variant number reserved. no functionality associated. ? version: version number version number of the module. no functionality associated. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 ---- variant 15 14 13 12 11 10 9 8 ---- version[11:8] 76543210 version[7:0]
968 42023e?sam?07/2013 atsam4l8/l4/l2 36.8 module configuration the specific configuration for each gloc instance is listed in the following tables.the gloc bus clocks listed here are connected to the system bus clocks. refer to section 10. ?power man- ager (pm)? on page 108 for details. table 36-4. gloc configuration feature gloc number of lut units 2 table 36-5. gloc clocks clock name description clk_gloc clock for the gloc bus interface gclk the generic clock used for the gloc is gclk5 table 36-6. register reset values register reset value version 0x00000102 parameter 0x00000002
969 42023e?sam?07/2013 atsam4l8/l4/l2 37. analog comparator interface (acifc) rev: 1.0.0.0 37.1 features ? controls an array of analog comparators ? low power option ? single shot mode support ? window mode ? detect inside/outside window ? detect above/below window ? interrupt ? on comparator result rising edge, falling edge, toggle, comparison done ? inside window, outside window, toggle ? when startup time is over ? peripheral events ? comparators triggered by incoming peripheral events ? configurable generated peripheral events 37.2 overview the analog comparator interface (acifc) controls a number of analog comparators (ac) with identical behavior. each analog comparator compares two voltages and gives a compare out- put depending on this comparison. a specific ac is referred to as acx where x is any number from 0 to n and n is the index of last ac module (refer to the module configuration section at the end of this chapter for details). the acifc can be configured in normal mode using each comparator independently or in win- dow mode using defined comparator pairs (acx and acx +1 ) to observe a window. the number of analog comparators implemented is device specific. refer to the module config- uration section for details.
970 42023e?sam?07/2013 atsam4l8/l4/l2 37.3 block diagram figure 37-1. acifc block diagram 37.4 i/o lines description ... trigger peruipheral events irq peripheral bus acifc analog comparators peripheral event generation - + ac0 inn inp ac0_inseln - + ac1 inn inp ac1_inseln interrupt generation clk_acifc actest actest1 actest0 acan0 a c a p 0 acbp0 acbn0 acout0 acout1 ac0_hys ac0_fast ac1_hys ac1_fast table 37-1. i/o line description pin name pin description type acapx positive reference pin for analog comparator x analog acanx negative reference pin for analog comparator x analog acbpx positive reference pin for analog comparator x analog acbnx negative reference pin for analog comparator x analog table 37-2. pin mapping channel pins (normal mode) window pair pins (window mode) 0 acap0, acan0 0 acap0, acbn0 1 acbp0, acbn0 2 acap1, acan1 1 acap1, acbn1 3 acbp1, acbn1
971 42023e?sam?07/2013 atsam4l8/l4/l2 37.5 product dependencies in order to use this module, other parts of the system must be configured correctly, as described below. 37.5.1 i/o lines the acifc pins are multiplexed with other peripherals. the user must first configure the i/o controller to give control of the pins to the acifc. 37.5.2 power management acifc stops functioning when the system enters a sleep mode that disables its clock. however, acifc can resume its operation if the system enters the sleepwalking mode and the acifc clock is started by the peripheral event system (see section 10. ?power manager (pm)? on page 108 for details on the sleepwalking mode). during this time, if acifc generates an interrupt, the system will wake up from sleep mode an d normal system operation will resume. 37.5.3 clocks the clock for acifc (clk_acifc) is generated by the power manager. it can be disabled either manually through the user interface of the power manager or automatically when the system enters a sleep mode that disables the clocks to the peripheral bus modules. 37.5.4 interrupts the acifc interrupt request line is connected to the nvic. using the acifc interrupt requires the nvic to be configured first. 37.5.5 peripheral events the acifc peripheral events are connected via the peripheral event system. refer to section 31. ?peripheral ev ent controller (pevc )? on page 844 for details. 37.5.6 debug operation when an external debugger forces the cpu into debug mode, the acifc continues normal operation. if the acifc is configured in a way that requires it to be periodically serviced by the cpu through interrupts or similar, improper operation or data loss may result during debugging. 37.6 functional description the acifc is enabled by writing a one to the c ontrol register enable bit (ctrl.en). addition- ally, the comparators must be individually enabl ed byselecting a measurement mode by writing to the mode field in the acx configuration register (confx.mode). the results from the individual comparators can either be used directly (normal mode), or the results from two comparators can be grouped to generate a comparison window (window mode). all comparators does not have to be in the same mode, some comparators may be in normal 4 acap2, acan2 2 acap2, acbn2 5 acbp2, acbn2 6 acap3, acan3 3 acap3, acbn3 7 acbp3, acbn3 table 37-2. pin mapping channel pins (normal mode) window pair pins (window mode)
972 42023e?sam?07/2013 atsam4l8/l4/l2 mode, while others are in window mode. there are restrictions on which acs can be grouped in a window mode, see section 37.6.5 . 37.6.1 analog comparator operation each ac can be in one of four measurement modes, determined by confx.mode: ? no measurement ? continuous measurement mode (cm) ? user triggered single measurement mode (ut) ? peripheral event triggered single measurement mode (et) an ac is disabled between measurements if the always on bit in the corresponding confx reg- ister (confx.alwayson) is zero. this is the default value after reset. this reduces the ac power dissipation between measurements, but the ac output will not be available until after an ac startup time. if the acx ready bit in the st atus register (sr.acrdyx) is one, the output of acx is ready. in window mode the result is available when both the comparator outputs are ready (sr.acrdyx=1 and sr.acrdyx+1=1). an ac is always enabled (i.e., during and between measurements) if the corresponding confx.alwayson bit is one. this allows a me asurement on ac to be made quickly after a measurement is triggered, without waiting for the ac startup time (except for the first startup after reset). 37.6.1.1 continuous measurement mode in the cm mode, ac is performing comparisons continuously. therefore the result of the latest comparison is always available in the acx curren t comparison status bit in the status register (sr.accsx). comparisons result are updated on every positive edge of clk_acifc. cm is enabled by writing confx.mode to one. when the corresponding ac is ready, sr.acrdyx is set and comparison st atus is reflected in sr.accsx. corresponding peripheral events and interrupts are generated if enabled. new comparisons are performed continuously until the conf x.mode field is written to zero. 37.6.1.2 user triggered single measurement mode in the ut mode, the user starts a single comparison by writing a one to the user start single comparison bit (ctrl.ustart). this mode is enabled by writin g confx.mode to 2. once the corresponding ac is ready, user can start a single comparison then sr.accs x is updated accordin gly. ctrl.ustart is cleared automatically by hardware when the single comparison has been done. corresponding peripheral events and interrupts are generated if enabled. 37.6.1.3 peripheral event triggered single measurement mode this mode is enabled by writing confx.mode to 3 and the peripheral event trigger enable bit in ctrl (ctrl.eventen) to one. the et mode is similar to the ut mode , the difference is that a peripheral event from another hardware module causes the hardware to automatically set the peripheral event start single comparison bit (ctrl.estart). once the corresponding ac is ready, an event starts a single comparis on then sr.accsx is updated accordingly. ctrl.estart is cleared automatically by hardware when the single comparison has been done.
973 42023e?sam?07/2013 atsam4l8/l4/l2 corresponding peripheral events and interrupts are generated if enabled. no new comparisons will be performed. 37.6.1.4 selecting comparator inputs each analog comparator has one positive (i np) and one negative (inn) input. the positive input is fed from an external input pin (acapx, acbpx). there are several sources for negative input including external input pin aca/bnx. the negative input select field (confx.inseln) selects the source for the negative input. see confx.inseln: nega tive input select table in module configuration section. note that in window mode, the negative input acanx and positive input acbpx+1 must have the same source, as shown in figure 37-2 . 37.6.2 interrupt generation the acifc has several interrupt sources. the status of each interrupt source can be read from the interrupt st atus register (isr). an interrupt reques t will be generated if a bit in isr and the corresponding bit in the interrupt mask register (imr) are set. bits in imr are set by writing a one to the corresponding bit in the interrupt enable register (ier), and cleared by writing a one to the corresponding bit in the interrupt disable register (idr). the interrupt request remains active until the corresponding bit in isr is cleare d by writing a one to the corresponding bit in the interrupt status clear register (icr). the interrupt sources are ored together to form one interrupt request. the acifc will generate an interrupt request if at least one the bits in imr is set. because all the interrupt sources are ored togheter, the interrupt reques t from the acifc will remain active utnil all the bits in isr are cleared. 37.6.3 peripheral event generation the acifc can be set up so that certain compar ison results notify other parts of the device via the peripheral event system. refer to section 37.6.4.3 and section 37.6.5.3 for information on which comparison results can generate peripheral events, and how to configure the acifc to achieve this. zero or one peripheral event will be generated per comparison. 37.6.4 normal mode in normal mode all analog comparators are operating independently. 37.6.4.1 normal mode output each analog comparator generates one output acout according to the input voltages on inp (ac positive input) and inn (ac negative input): ? acout = 1 if v inp > v inn ? acout = 0 if v inp < v inn ? acout = 0 if the ac output is not available (sr.acrdy = 0) the output can optionally be filtered, as described in section 37.6.6 . 37.6.4.2 normal mode interrupt there are two types of interrupt for each ac:
974 42023e?sam?07/2013 atsam4l8/l4/l2 ? startup time interrupt (bit isr.sutintx), each ac can generate an interrupt when the startup time is over. ? ac output based interrupt (bit isr.acintx). in normal mode, the following interrupt sources are available: ? when v inp > v inn ? when v inp < v inn ? on toggle of the ac output (acout) ? when comparison has been done the user selects the interrupt source by writing to the interrupt settings field in the acx configu- ration register (confx.is). 37.6.4.3 normal mode peripheral events the acifc can generate peripheral events acco rding to the configuration of confx.evenn and confx.evenp. ? when v inp > v inn or ? when v inp < v inn 37.6.5 window mode window mode is enabled by writing a one to th e window mode enable bit in the window config- uration register (confwx.wf en). two acs, acx and acx +1 , (an even and the following odd build up a pair) are grouped if window mode is enabled by writing confwx.wfen. the sources of the negative input of acx (even) and the positive input of acx +1 (odd) must be connected together externally. the negative input select field in the acx configuration register (confx.inseln) must select the corresponding external input pin (acanx) as the source to the negative input of acx. the negative input of acx+1 can still be selected independently by confx+1.inseln.
975 42023e?sam?07/2013 atsam4l8/l4/l2 figure 37-2. analog comparator interface in window mode 37.6.5.1 window mode output when operating in window mode, each ac generates the same acout outputs as in normal mode, see section 37.6.4.1 . additionally, the acifc generates a window mo de signal (acwout) according to the common input voltage to be compared: ? acwout = 1 if the common input voltage is inside the window, v acbnx+1 < v common < v acapx ? acwout = 0 if the common input voltage is outside the window, v common < v acanx+1 or v common > v acapx ? acwout = 0 if the window mode output is not available (sr.acrdyx=0 or sr.acrdyx+1=0) the windowx mode current status bit in sr (sr.wfcsx) gives the comparison status of the window pair. 37.6.5.2 window mode interrupts when operating in window mode, each ac can generate the same interrupt as in normal mode, see section 37.6.4.2 . additionally, when acs operate in window mode, a third type of interrupt based on acwout can be generated (bit isr.wfintx). writing to window mode interrupt settings in windowx mode configuration register (con- fwx.wis) selects an interrupt source: ? as soon as the common inpu t voltage is inside the window. ? as soon as the common input voltage is outside the window. comparator pair - + acx interrupt generator window module acoutx peripheral event generator window window mode peripheral event - + acx+1 sr.accsn sr.wfcsn acapx acanx acbpx common acwout acbnx irq acoutx+1 confx.inseln confx+1.inseln
976 42023e?sam?07/2013 atsam4l8/l4/l2 ? on toggle of the window compare output (acwout). ? when the comparison in both acs in the window mode is ready. ? when the common input voltage enters the window (i.e., rising-edge of acwout). ? when the common input voltage leaves t he window (i.e., falling-edge of acwout). 37.6.5.3 window mode peripheral events when operating in window mode, each ac can gene rate the same peripheral events as in nor- mal mode, see section 37.6.4.3 . additionally, user enables generation of window peripheral events by writing a one to the win- dow peripheral event enable bit (confwx.wfen). writing to window mode peripheral event selection source (confwx.wevsrc) selects the peripheral events source: ? as soon as the common inpu t voltage is inside the window. ? as soon as the common input voltage is outside the window. ? on toggle of the window compare output (acwout) ? whenever a comparison is ready and the common input voltage is inside the window. ? whenever a comparison is ready and the common input voltage is outside the window. ? when the comparison of both acs in the window mode is ready. 37.6.6 analog hysteresis control the user can select the hysteresis voltage used by each ac to reduce noise in its output. as shown in figure 37-3 , the output of the ac switches from zero to one when the differential volt- age v d (= v inp - v inn ) is greater than (hysteresis voltage / 2) and switches from one to zero when v d is less than (hysteresis voltage / 2). the hyster esis voltage for each ac is selected by writing to the hysteresis voltage field in the confx register (confx.hys), as shown in table 37-3 . figure 37-3. hysteresis voltage acout v d = v inp ? v inn vdd hysteresis voltage table 37-3. hysteresis voltage selection confx.hys hysteresis voltage (mv) 00 125 250 375
977 42023e?sam?07/2013 atsam4l8/l4/l2 37.6.7 power dissipation and speed trade-off acifc is able to control whether an ac operates in fast or low-power mode, allowing a trade-off between its active power dissipation and speed. the desired mode is selected by writing to the fast bit in the confx register (confx.fast). when confx.fast is zero (default), the corre- sponding ac operates in low-power mode. when confx.fast is one, it operates in fast mode. in low-power mode, the ac dissi pates significantly less active power than when it is in fast mode, but has a longer start-up time and propagation delay. refer to section 42. ?electrical characteristics? on page 1120 for details. 37.6.8 wake up from sleep modes by interrupt an ac is able to wake up the system from a sleep mode by its interrupt, including sleep modes where clk_acifc is stopped. for an ac to wake up the system, the user must follow this pro- cedure before the system enters a sleep mode: ? set ac in the continuous measurement mode (confx.mode). ? set the ac?s interrupt setting (confx.is =2) so that it generates an interrupt on the toggling of the corresponding ac output. ? wait for ac to be ready (sr.acrdyx = 1). once acifc detects a transition on the relevant ac output, it sends a request to power man- ager for clk_acifc to restart (the corresponding bit in the power manager peripheral power control register (ppcr) must be set) and sets the corresponding interrupt status bit in isr after clk_acifc has restarted. note that in order for the interrupt from acifc to wake up the sys- tem, the acifc bit in the power manager asynchronous wake up enable register (awen) must be set. 37.7 peripheral event triggers peripheral events from other modules can trigger comparisons in the acifc. all acs that are configured in peripheral event triggered singl e measurement mode will be started simultane- ously when a peripheral event is received. ac s operating in continuous measurement mode or user triggered single measurement mode are unaffected by the received peripheral event. soft- ware can still operate these acs independently of acs in peripheral event triggered single measurement mode. a peripheral event will trigger one or more comparisons, in normal or window mode. 37.8 ac test mode by writing a one to the analog comparator test mode bit (cr.actest), the outputs from the acs are overridden by the value in the test register (tr), see figure 37-1 . this can be useful for software tests.
978 42023e?sam?07/2013 atsam4l8/l4/l2 37.9 user interface note: 1. the reset values for these registers are device specific. refer to the module configuration section at the end of this c hapter. 2. number of ac and ac pair is device specif ic therefore associated register may not exist. table 37-4. acifc register memory map offset register register name access reset 0x00 control register ctrl read/write 0x00000000 0x04 status register sr read-only 0x00000000 0x10 interrupt enable register ier write-only 0x00000000 0x14 interrupt disable register idr write-only 0x00000000 0x18 interrupt mask register imr read-only 0x00000000 0x1c interrupt status register isr read-only 0x00000000 0x20 interrupt status clear register icr write-only 0x00000000 0x24 test register tr read/write 0x00000000 0x30 parameter register parameter read-only - (1) 0x34 version register version read-only - (1) 0x80 window0 configuration register (2) confw0 read/write 0x00000000 0x84 window1 configuration register (2) confw1 read/write 0x00000000 0x88 window2 configuration register (2) confw2 read/write 0x00000000 0x8c window3 configuration register (2) confw3 read/write 0x00000000 0xd0 ac0 configuration register (2) conf0 read/write 0x00000000 0xd4 ac1 configuration register (2) conf1 read/write 0x00000000 0xd8 ac2 configuration register (2) conf2 read/write 0x00000000 0xdc ac3 configuration register (2) conf3 read/write 0x00000000 0xe0 ac4 configuration register (2) conf4 read/write 0x00000000 0xe4 ac5 configuration register (2) conf5 read/write 0x00000000 0xe8 ac6 configuration register (2) conf6 read/write 0x00000000 0xec ac7 configuration register (2) conf7 read/write 0x00000000
979 42023e?sam?07/2013 atsam4l8/l4/l2 37.9.1 control register name: ctrl access type: read/write offset: 0x00 reset value: 0x00000000 ? actest: analog comparator test mode 0: the analog comparator outputs ar e connected to the logic in acifc. 1: the analog comparator outputs ar e bypassed with the ac test register. ? estart: peripheral event start single comparison writing a zero to this bit has no effect. writing a one to this bit starts a comparison and can be used for test purposes. this bit is cleared when comparison is done. this bit is set when an enabled peripheral event is received. ? ustart: user start single comparison writing a zero to this bit has no effect. writing a one to this bit starts a single comparison. this bit is cleared when comparison is done. ? eventen: peripheral event trigger enable 0: a peripheral event will not trigger a comparison. 1: enable comparison triggered by a peripheral event. ? en: acifc enable 0: the acifc is disabled. 1: the acifc is enabled. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 ------- - 15 14 13 12 11 10 9 8 - ------- 76543210 actest - estart ustart - - eventen en
980 42023e?sam?07/2013 atsam4l8/l4/l2 37.9.2 status register name: sr access type: read-only offset: 0x04 reset value: 0x00000000 ? wfcsx: windowx mode current status this bit is cleared when the common input voltage is outside the window. this bit is set when the common input voltage is inside the window. ? acrdyx: acx ready this bit is cleared when the ac output (acout) is not ready. this bit is set when the ac output (acout) is ready, ac is enabled and its startup time is over. ? accsx: acx current comparison status this bit is cleared when v inp is currently lower than v inn this bit is set when v inp is currently greater than v inn. 31 30 29 28 27 26 25 24 ----wfcs3wfcs2wfcs1wfcs0 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 acrdy7 accs7 acrdy6 accs6 acrdy5 accs5 acrdy4 accs4 76543210 acrdy3 accs3 acrdy2 accs2 acrdy1 accs1 acrdy0 accs0
981 42023e?sam?07/2013 atsam4l8/l4/l2 37.9.3 interrupt enable register name: ier access type: write-only offset: 0x10 reset value: 0x00000000 writing a zero to a bit in this register has no effect. writing a one to a bit in this register will set the corresponding bit in imr. 31 30 29 28 27 26 25 24 - - - - wfint3 wfint2 wfint1 wfint0 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 sutint7 acint7 sutint6 acint6 sutint5 acint5 sutint4 acint4 76543210 sutint3 acint3 sutint2 acint2 sutint1 acint1 sutint0 acint0
982 42023e?sam?07/2013 atsam4l8/l4/l2 37.9.4 interrupt disable register name: idr access type: write-only offset: 0x14 reset value: 0x00000000 writing a zero to a bit in this register has no effect. writing a one to a bit in this register will clear the corresponding bit in imr. 31 30 29 28 27 26 25 24 - - - - wfint3 wfint2 wfint1 wfint0 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 sutint7 acint7 sutint6 acint6 sutint5 acint5 sutint4 acint4 76543210 sutint3 acint3 sutint2 acint2 sutint1 acint1 sutint0 acint0
983 42023e?sam?07/2013 atsam4l8/l4/l2 37.9.5 interrupt mask register name: imr access type: read-only offset: 0x18 reset value: 0x00000000 0: the corresponding interrupt is disabled. 1: the corresponding interrupt is enabled. a bit in this register is cleared when the corresponding bit in idr is written to one. a bit in this register is set when the corresponding bit in ier is written to one. 31 30 29 28 27 26 25 24 - - - - wfint3 wfint2 wfint1 wfint0 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 sutint7 acint7 sutint6 acint6 sutint5 acint5 sutint4 acint4 76543210 sutint3 acint3 sutint2 acint2 sutint1 acint1 sutint0 acint0
984 42023e?sam?07/2013 atsam4l8/l4/l2 37.9.6 interrupt status register name: isr access type: read-only offset: 0x1c reset value: 0x00000000 ? wfintx: windowx mode interrupt status 0: no window mode interrupt is pending. 1: window mode interrupt is pending. this bit is cleared when the corresponding bit in icr is written to one. this bit is set when the corresponding acs pair operating in wi ndow mode generates an interrupt (see confwx to select the source). ? sutintx: acx startup time interrupt status 0: no startup time interrupt is pending. 1: startup time interrupt is pending. this bit is cleared when the corresponding bit in icr is written to one. this bit is set when the startup time of the corresponding ac is over. ? acintx: acx interrupt status 0: no normal mode interrupt is pending. 1: normal mode interrupt is pending. this bit is cleared when the corresponding bit in icr is written to one. this bit is set when the corresponding ac generates an interrupt (see confx to select the source). 31 30 29 28 27 26 25 24 - - - - wfint3 wfint2 wfint1 wfint0 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 sutint7 acint7 sutint6 acint6 sutint5 acint5 sutint4 acint4 76543210 sutint3 acint3 sutint2 acint2 sutint1 acint1 sutint0 acint0
985 42023e?sam?07/2013 atsam4l8/l4/l2 37.9.7 interrupt status clear register name: icr access type: write-only offset: 0x20 reset value: 0x00000000 writing a zero to a bit in this register has no effect. writing a one to a bit in this register will clear the corresponding bit in isr and the corresponding interrupt request. 31 30 29 28 27 26 25 24 - - - - wfint3 wfint2 wfint1 wfint0 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 sutint7 acint7 sutint6 acint6 sutint5 acint5 sutint4 acint4 76543210 sutint3 acint3 sutint2 acint2 sutint1 acint1 sutint0 acint0
986 42023e?sam?07/2013 atsam4l8/l4/l2 37.9.8 test register name: tr access type: read/write offset: 0x24 reset value: 0x00000000 ? actestx: acx output override value 0: normal operating mode. 1: if ctrl.actest is one, acx output is the bit value actestx. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------- 76543210 actest7 actest6 actest5 actest4 a ctest3 actest2 actest1 actest0
987 42023e?sam?07/2013 atsam4l8/l4/l2 37.9.9 parameter register name: parameter access type: read-only offset: 0x30 reset value: - ? wimplx: window x mode implemented 0: window x mode is not implemented. 1: window x mode is implemented. ? acimplx: analog comp arator x implemented 0: analog comparator x is not implemented. 1: analog comparator x is implemented. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 - - - - wimpl3 wimpl2 wimpl1 wimpl0 15 14 13 12 11 10 9 8 -------- 76543210 acimpl7 acimpl6 acimpl5 acimpl4 acimpl3 acimpl2 acimpl1 acimpl0
988 42023e?sam?07/2013 atsam4l8/l4/l2 37.9.10 version register name: version access type: read-only offset: 0x34 reset value: - ? variant: variant number reserved. no functionality associated. ? version: version number version number of the module. no functionality associated. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 ---- variant 15 14 13 12 11 10 9 8 - - - - version[11:8] 76543210 version[7:0]
989 42023e?sam?07/2013 atsam4l8/l4/l2 37.9.11 windowx configuration register name: confwx access type: read/write offset: 0x80,0x84,0x88,0x8c reset value: 0x00000000 ? wfen: window mode enable 0: window mode is disabled. 1: window mode is enabled. ? weven: window peripheral event enable 0: peripheral event from acwout is disabled. 1: peripheral event from acwout is enabled. 31 30 29 28 27 26 25 24 ------- - 23 22 21 20 19 18 17 16 -------wfen 15 14 13 12 11 10 9 8 - - - - weven wevsrc 7654321 0 ----- wis
990 42023e?sam?07/2013 atsam4l8/l4/l2 ? wevsrc: peripheral event sour ce selection for window mode ? wis: window mode interrupt settings wevsrc peripheral source selection 0 0 0 acwout rising edge 0 0 1 acwout falling edge 0 1 0 acwout rising or falling edge 0 1 1 inside window 1 0 0 outside window 1 0 1 measure done 110reserved 111reserved wis interrupt settings 0 0 0 window interrupt as soon as the common input voltage is inside the window 0 0 1 window interrupt as soon as the common input voltage is outside the window 0 1 0 window interrupt on toggle of acwout 0 1 1 window interrupt when evaluation of common input voltage is done 1 0 0 window interrupt when the common input voltage enters the window (i.e., rising-edge of acwout) 1 0 1 window interrupt when the common input voltage leaves the window (i.e., falling-edge of acwout) 110reserved 111reserved
991 42023e?sam?07/2013 atsam4l8/l4/l2 37.9.12 acx configuration register name: confx access type: read/write offset: 0xd0,0xd4,0xd8,0xdc,0xe0,0xe4,0xe8,0xec reset value: 0x00000000 ? alwayson: always on 0: ac is disabled between measurements 1: ac is always enabled ? fast: fast mode enable this bit controls whether the ac operates in fast or lo w-power mode, thus allowing a trade-off between its active power dissipation and speed (i.e., startup time and propagation delay): 0: low-power mode 1: fast mode refer to section 42. ?electrical characteristics? on page 1120 for details on the current consumption, start-up time, and propagation delay of the ac when it is in either of these modes. ? hys: hysteresis voltage value. ? evenn: peripheral ev ent enable negative 0: do not output peripheral event when acout is zero. 1: output peripheral event when acout is zero. ? evenp: peripheral ev ent enable positive 0: do not output peripheral event when acout is one. 1: output peripheral event when acout is one. ? inseln: negative input select see confx.inseln: nega tive input select table in module configuration section. 31 30 29 28 27 26 25 24 -- -- alwayson fast hys 23 22 21 20 19 18 17 16 - - - - - - evenp evenn 15 14 13 12 11 10 9 8 ----- - inseln 7654321 0 -- mode -- is hys hysteresis value 0 0 hysteresis voltage = 0 mv 0 1 hysteresis voltage = 25 mv 1 0 hysteresis voltage = 50 mv 1 1 hysteresis voltage = 75 mv
992 42023e?sam?07/2013 atsam4l8/l4/l2 ? mode: analog comparator mode ? is: interrupt settings mode mode selected 00off 0 1 continuous measurement mode 1 0 user triggered single measurement mode 1 1 peripheral event triggered single measurement mode is interrpt setting 0 0 when v inp > v inn 0 1 when v inp < v inn 1 0 on toggle of acout 1 1 when comparison of v inp and v inn is done
993 42023e?sam?07/2013 atsam4l8/l4/l2 37.10 module configuration the specific configuration for each acifc instance is listed in the following tables.the module bus clocks listed here are conn ected to the system bus clocks. refer to the power manager chapter for details. table 37-5. acifc configuration feature acifc ac_no 8 acw_no 4 table 37-6. acifc clocks clock name description clk_acifc clock for the acifc bus interface table 37-7. confx.inseln: nega tive input select inseln input selected 0 0 acanx (acbnx) pin selected 01 reserved 10 reserved 11 reserved table 37-8. register reset values register reset value version 0x00000100 pa rameter 0x0003000f
994 42023e?sam?07/2013 atsam4l8/l4/l2 38. adc interface (adcife) rev. 1.0.0.0 38.1 features ? multi-channel analog-to-digital co nverter with 12-bit resolution ? selectable single ended or differential input voltage ? programmable gain per conversion ? selectable adc voltage input reference per conversion ? numerous trigger sources ? software ? embedded 16-bit timer for periodic trigger ? continuous trigger ? peripheral event trigger ? external trigger, rising, falling or any-edge trigger ? multiple sequencer modes: ? run multiple sequences using dma transfer ? run a single conversion on a start-of-conversion ? start of conversion or sequ ence without cpu intervention ? adc power reduction mode fo r low power adc applications ? window monitor, with selectab le channel per conversion ? programmable sample & hold time per conversion 38.2 overview the adc interface (adcife) converts analog inpu t voltages to digital values. the adcife is based on a 12-bit cyclic pipeline topology to achieve sampling rates up to 300 ksps (in differ- ential mode without gain). the adc conversion results are reported in a common register for all channels. conversions can be started for all enabled channels, either by a software trigger, by detection of a level change on the external trigger pin or event system, or by an integrated programmable 16-bit timer. this adc has selectable single-ended or fully di fferential inputs and takes benefits from a pro- grammable gain from x0.5 to x64 included. the conversions extend from -vref to +vref. 16 external channels on both positive and negative inputs can be managed. the adcife also integrates an power reduction mode, a window monitor mode, and connects with two peripheral dma controller channels (one rx for configuration and one tx for transfer- ing results). these features reduce both power consumption and processor intervention.
995 42023e?sam?07/2013 atsam4l8/l4/l2 38.3 block diagram figure 38-1. adcife block diagram 38.4 i/o lines description 38.5 product dependencies 38.5.1 i/o lines the pins used for interfacing the adcife may be multiplexed with i/o controller lines. the pro- grammer must first program the i/o controller to assign the desired adcife pins to their ad0 ad1 ad2 adn sequencer adcife gclk gndref gpio controller neg analog mux trigger s election trigger/pevc sources timer interrupt request dma request adcife_pevc_eoc clk_adcife user interface adcife_pevc_wm 12-bit cyclic pipeline adc core advrefp pos analog mux peripheral bus reference buffer clock generator clk_adcife bandgap external r ef. table 38-1. i/o lines decription table name description ty p e ad0-ad14 analog input channels analog external ref. 2 external voltage references analog a33vdd analog power supply power a33gnd analog ground power adtrg external trigger digital
996 42023e?sam?07/2013 atsam4l8/l4/l2 peripheral function. if i/o lines of the adcife ar e not used by the application, they can be used for other purposes by the i/o controller. 38.5.2 power management if the cpu enters a power redu ction mode that disables cl ocks used by the adcife, the adcife will stop functioning and resume operat ion after the system wakes up from power reduction mode. before entering a power reduction mode where the clock to the adcife is stopped, make sure the analog-to-digital co nverter cell is put in an inactive state. if an event is sent to the adcife and the cl ocks used by the adcife are stopped, the adcife clock will automatically be requested so that the conversion can be processed. 38.5.3 clocks the clock for the adcife bus interface (clk _adcife) is generated by the power manager. this clock is disabled at reset, and can be enabled/disabled in the power manager. it is recom- mended to disable the adcife before disabling t he clock, to avoid freezing the adcife in an undefined state. additionally, the adcife depends on a dedicated generic clock (gclk). the gclk can be set to a wide range of frequencies and clock sources, and must be enabled by the system control interface (scif) before the adcife can be used. this gclk can also be muxed with the clk_adcife clock by writting the clock selection bit in the configuration regi ster (cfg.clksel). it is used during the sleep walking mode. 38.5.4 interrupt controller the adcife interrupt line is connected on one of the internal sources of the interrupt controller. using the adcife requires the interrupt controller to be programmed first. 38.5.5 event system the event controller provides the adcife a trigger source. the adcife also behaves as an event source: ? event on an end of conversion ( figure 38-1 adcife_pevc_eoc signal) ? event on a window monitor trigger ( figure 38-1 adcife_pevc_wm signal) to operate correctly, the event source period should not exceed the ad c conversion time plus the startup time if needed. refer to the peripheral event system chapter for details. 38.6 section 42. ?electrical characteristics? on page 1120 functional description 38.6.1 initializing the adcife to initialize the module the user first needs to configure the adcife clocks (refer to section 38.5.3 ). then he needs to wait for the startup time (refer to section 38.6.7 ) (if necessary). then he can write a one to the enable (en) bit in the control register (cr). the user must check that adcife has started correctly, firstly by checking that the enable bit (en) located in the status register (sr) is set. the bandgap buffer request bit in the control register (cr.bgreqen) and the reference buffer enable in the control register (cr.refbufen) must be set. if the reference buffer of the adc cell is enabled and ready for use, sr.en can tell if the adcife is ready for operation si nce startup-time will be performed only wh en a sequencer trig- ger event occurs if necessary.
997 42023e?sam?07/2013 atsam4l8/l4/l2 note that all adcife controls will be ignored until sr.en goes to ?1?. before the adcife can be used, the internal reference voltage signal must be selected by writ- ing the cfg.refsel field and the i/o controller must be configured correctly. refer to i/o controller section for details. the user must also configure the frequency range by writting the cfg.speed field. note that once configured, adcife configuration registers should not be written during opera- tion since they are permanently used by the adcife. the user must ensure that adcife is stopped during configuration unless he knows what he is doing. 38.6.2 basic operation to convert analog values to digital values the user must first initialize the adcife as described in section 38.6.1 . when the adcife is initialized, the sequencer must be configured by writing into the sequencer configuration register (seqcfg) all the necessary bits or fields for the next conversion. this configuration can also be pe rformed by peripheral dma rx channel access. configuring channel n for a given conversion instructs the adcife to convert the analog voltage applied to ad pin n. to start converting data the user can either manually start a conversion sequence by write a one to the sequencer trigge r event (strig) bit in t he control register (cr) or configure an automatic trigger to initiate the conversions. the automatic trigger can be config- ured to trig on many different conditions. refer to section 38.6.13 for details. the result of the conversions are stored in the last converted value register (lcv) as they become available, overwriting the result from the previous conversion. to avoid data loss, the user must read the conversion results as they become available either by using an interrupt handler or by using a peripheral dma channel to copy the results to memory . failing to do so will re sult in an overrun error condition, indicated by the lovr bit in the status register (sr). to use an interrupt han- dler the user must enable the end of conversion (eoc) interrupt request by writing a one to the corresponding bit in the interrupt enable register (i er). to clear the interrupt after the conver- sion result is read, the user must write a one to the corresponding bit in the status clear register (scr). to use a peripheral dma controller tx channel, the user must configure the peripheral dma controller appropriately. the dma controller will, when configured, automatically read con- verted data as they become available. there is no need to manually clear any bits in the interrupt status register as this is performed by the hardware. if an overrun error condition hap- pens during dma operat ion, the lovr bit in the sr will be set. 38.6.3 adc resolution this adc is a cyclic pipeline 12-bit or 8-bit resolution. resolution can be changed by writing the resolution field (res) in the sequencer configuration register (seqcfg). by default, after a reset, the resolution is set to 12-bit. 38.6.4 differential and single-ended conversion modes the adc has two conversion modes; different ial and single-ended. if measuring signals where the positive input is always at a higher voltag e than the negative input, the single-ended conver- sion mode should be used in order to have full 12-bit resolution in the conversion mode, which has only positive values. if however the positive input may go below the negative input creating some negative results, the differential mode should be used in order to get correct results. the configuration of the conversion mode is set in the field bipolar in seqcfg (seqcfg.bipolar).
998 42023e?sam?07/2013 atsam4l8/l4/l2 note that the adc works differenti ally in single-ended mode as well, as long as the positive input has a higher voltage than the negative. 38.6.5 adc clock configuration the adcife generates an internal clock named clk_adc that is used by the analog-to-digital converter cell to pe rform conversions. the clk_adc is sele cted by writing to the clksel bit in the configuration register (cfg). the clk_adc frequency is the frequency of the clock selected by the clksel bit divided by the prescaler field in the configuration register(cfg.prescal). the value of th frequency must be defined in order to provide an adc clock frequency according to the maximum sampling rate parameter given in the electrical characteristics section. failing to do so may result in incorrect analog-to-digital converter operation. the adc cell converts an input voltage in 6 clk_adc periods and takes at least shtim+1 gclk periods to sample for a 12-bit resolution. thus, the maximum achievable adc sampling frequency is: if a 8-bit result is generated, the maximum adc sampling frequency is 38.6.6 power reduction mode the power reduction mode maximizes power saving by automatically deactivating the analog- to-digital converter cell when it is not being used for conversions. the power reduction mode is enabled by writing a one to the disable adc( dis) bit in the contro l register (cr.dis). before entering power reduction mode the user must make sure the adcife is idle and that the analog-to-digital converter cell is inactive. to make sure the adcife is idle, write a zero to the trigger selection (trgsel) field in the sequenc er configuration register (seqcfg) and wait for the sequencer busy (sbusy) bit in the status register (sr) to be cleared. note that by deactivating the analog-to-digital converter cell, a startup time penalty as defined in the startup field in the timi ng register (tim) will apply on the next conversion. the adcife has the possibility to adjust the po wer consumption of the adc cell according to the frequency range used. the speed field in the cfg register must be written to the right value. 38.6.7 power-up and startup time the analog-to-digital converter cell has a start up time when the cell is activated for the first time. this startup time is at least 12 adc_ clk. this timing should be manage by the user by setting the startup time field in the timing c onfiguration register (tim.startup). the enable startup bit in the timing configuration register (tim.enstup) allows to enable or not the startup time. for power-up and startup time values of the adc cell, refer to the adc cell chapter. 38.6.8 operation start/stop to reset adcife to its initial st ate, user can enable the adcife after it was previously disabled thanks to the enable bit in the control register (cr.en) and the disable bit in the control register fclkadc () 6 --------------------------------- - fclkadc () 4 --------------------------------- -
999 42023e?sam?07/2013 atsam4l8/l4/l2 (cr.dis). another way to reset adcife is to write a one in the swrst field of the control reg- ister (cr.swrst). in both cases configuration registers won?t be affected. 38.6.9 analog reference refer to section 42. ?electrical characteristics? on page 1120 . the adc allows the possibility to sele ct several voltage reference (vref). ? an internal 1.0v voltage reference derived from the internal 1.1v ? 0.625*vcc (to get 1.0v when vcc=1.6v) ?vcc/2 ? 2 external reference inputs 38.6.10 gain the adc cell allows to affect different gain for each conversion by configuring approprietely the gain factor field gain in the seqcfg register. the programmable input amplification is from 1x to 64x. moreover, this amplification can be divided by 2 by setting all bits in the field gain in the seqcfg register to seven. 38.6.11 conversion results if the half word left adjust (h wla) bit in the seqcfg register is set, then the result will be left adjusted on the 16 lower bits of the lcv register. otherwis e, results will be right-adjusted. positive and negative channels used in the last conversion are available both by reading the sequencer last converted value register (lcv). 38.6.12 operating modes overview table 38-2. operating modes description operating mode input range output code range conversion time output decimal code differential mode without gain -vref to + vref 0 to 4095 (11 bits signed number) 6 clock_cycles 2047 + (vin/vref)*2047 differential mode with gain=2n -vref/2 n to +vref/2 n 0 to 4095 (11 bits signed number) 7 clock_cycles for n=1 (gain=2) 9 clock_cycles for n=6 (gain=64) 2047 + (2 n *vin/vref)*2047 differential mode with divi- sion by 2 -2*vref to +2*vref 0 to 4095 (11 bits signed number) 7 clock_cycles 2047 + (vin/(2*vref))*2047 differential mode with zoom and gain =2n (n>0) -vref/2n+vshift, vref/2n+vshift vshift=vsup(1/4* zoom- range[1]+1/8*zo omrange[0]) 0 to 4095 (11 bits signed number) 7 clock_cycles for n=1 (gain=2) 10 clock_cycles for n=6 (gain=64) 2047+(2 n *(vin- vshift)/vref*2047
1000 42023e?sam?07/2013 atsam4l8/l4/l2 38.6.13 sequencer trigger event (strig) the sources must be configured through the trgsel field of the seqcfg register (seqcfg.trgsel). selecting the event controller source allows any event controller source to generate a sequencer trigger event (strig). by configuring the conti nuous mode, strig will be generated continuously. the adc can serve a maximum of one strig every 6+1 clk_adc periods. extra strig will be ignored. user will be informed thanks to the sequencer miss ed trigger event (smtrg) field of the sr register (sr.smtrg). if the strig frequency provided by the event controller exceeds the adc capability, the event cont roller will generate an underrun status. 38.6.14 internal timer the adcife embeds an internal 16-bit timer us ed as a trigger source which can be configured by setting the itmc field of the itimer register (itimer.itmc). internal timer trigger period= (itmc+1)*t(clk_adc) once set as a strig source, the internal timer has to be started by writing a '1' in the tstart bit of the cr register (cr.tstart). it can be stopped in the same way by writing a '1' in the tstop bit of the cr register (cr.tstop). the current status of the internal timer can be read unipolar mode without gain and without hystere- sis 0 to vref 0 to 4095 (12 bits unsigned number) 7 clock_cycles 4095*vin/vref unipolar mode without gain and with hysteresis (zoom- range[2]=1) -0.05*vref to 0.95*vref 0 to 4095 (12 bits unsigned number) 7 clock_cycles 4095*(vin+0.05*vref)/vref unipolar mode without hystere- sis and gain =2n 0 to vref/2 n 0 to 4095 (12 bits unsigned number) 7 clock_cycles for n=1 (gain=2) 10 clock_cycles for n=6 (gain=64) 4095*(2 n *vin)/vref unipolar mode without hystere- sis and with divi- sion by 2 0 to 2*vref 0 to 4095 (12 bits unsigned number) 7 clock_cycles 4095*(vin/2)/vref) unipolar mode with hysteresis and gain =2n (-0.05*vref to 0.95*vref) /2 n 0 to 4095 (12 bits unsigned number) 7 clock_cycles for n=1 (gain=2) 10 clock_cycles for n=6 (gain=64) 4095*(2 n *vin+0.05*vref)/vre f unipolar mode with hysteresis and with divi- sion by 2 -0.1*vref to 1.9*vref 0 to 4095 (12 bits unsigned number) 7 clock_cycles 4095*(0.5*vin+0.05*vref)/vr ef operating mode input range output code range conversion time output decimal code
1001 42023e?sam?07/2013 atsam4l8/l4/l2 from the timer busy field of the sr register (sr.tbusy): 0 means stopped, 1 means running. in addition when the internal timer is running, if itimer.itmc is written to change the internal timer timeout frequency, the internal counter is cleared to avoid rollover phenomena. note: it is possible to generate an internal timer event each gclk period by writing 0 in itimer.itmc and by selecting the internal timer as a strig source 38.6.15 peripheral dma cont roller (pdca) capability there are two pdca channels. one rx for tran sferring data result to memory, and one tx for storing the updated configuration of the next conversion from memory. the lcv register contains the last converted value of the sequencer according to the conversion result format. the lcv register is updated each time the sequencer ends a conversion. if the last converted value has not been read, there?s an overrun, the lovr bit in the sr register indi- cates that at least one overrun error occurred. the lovr bit of the sr register is cleared by writing a ?1? in the lovr field of the scr register. tx transfer: if the configuration is performed by the pdca, so the cdma register contains con- figuration for the next conversion. if window mode is not used, only one word is usefull with the msb bit to zero. if window mode is used, the first word has the msb bit to one and the second word is dedicated for window mode with msb bit set to zero. note: rx pdca transfers are 16 bits wide. note: in tx, the first word received has always the same structure. the second word, if neces- sary, has always the same structure too. figure 38-2. one dma tx transfer: no window mode configuration msb : 0 dma tx ready apb data bus dma word data start of conversion 31 30 29 28 27 26 25 24 0 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 tss res enstup 7654 3 210 gcomp strig bipolar hwla gain zoomrange muxneg internal muxpos dma word data with msb to "0" cdma register
1002 42023e?sam?07/2013 atsam4l8/l4/l2 figure 38-3. two dma tx transfers: with window mode configuration 38.6.16 zoom mode the zoom mode allows to choose a part of a range of the reference voltage (seqcfg.zoomrange) and spread it from 0 to 4095 decimal. this particular mode of the adc uses gain in which the input range is shifted with a programmable voltage. the input voltage range is acording to a progr ammable voltage of vdd and a range around this voltage (seqcfg.gain). 38.6.17 window monitor the window monitor monitors adc results and make the adcife behave as an analog compar- ator. configuration is done by writing appropriately the window configuration register (wcfg) and the window thresholds register (wth). when writing a one in the monitor filter mode bit in the wcfg register (wcfg.mfm) , conversions are filtered using its index in the sequence. oth- erwise, no filtering is applied, monitoring is performed on every conversion. index is given by writing the field source in the wcfg register (wcfg.src). supported modes are selected by writing the window mode field in the wcfg register, refer to the table 38-3 below. thresholds are given by writing the low threshold (lt) and high threshold (ht) in wth. note that the significant wth.lt and wt.ht bits are given by the precision selected in the seqcfg.res field. that means th at if you are in 8-bit mode, only the 8 lower bits will be considered. msb : 1 dma tx ready apb data bus 1st dma word data start of conversion 31 30 29 28 27 26 25 24 1 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 tss res enstup 7654 3 210 gcomp strig bipolar hwla gai n zoomrange mux neg internal mux po s first dma word data with msb to "1" cdma register 2nd dma word data msb : 0 31 30 29 28 27 26 25 24 0 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 76543210 lt[7:0] ht[11:8] ht[7:0] wm lt[11:8] second dma word data with msb to "0" cdma register
1003 42023e?sam?07/2013 atsam4l8/l4/l2 note: comparisons are performed regardless with the seqcfg.hwla setting (half word left adjust). 38.6.18 interrupts interrupt requests are enabled by writing a one to the corresponding bit in the interrupt enable register (ier) and disabled by writing a one to the corresponding bit in the interrupt disable register (idr). enabled interrupts can be read fr om the interrupt mask register (imr). active interrupt requests, but potentially masked, are visi ble in the status register (sr). to clear an active interrupt request, write a one to the corresponding bit in the clear register (cr). the status register (sr) fields in common with ier/idr/imr show the status since the last write to the interrupt clear register. other sr fields show the status at the time being read. 38.6.19 conversion performances for performance and electrical characteristics of the adcife, refer to section 42. ?electrical characteristics? on page 1120 . table 38-3. window monitor modes wm field in wcfgy modes 0 0 0 no window mode (default) 0 0 1 mode 1: active when result > lt 0 1 0 mode 2: active when result < ht 0 1 1 mode 3: active when lt < result < ht 1 0 0 mode 4: active when (!(lt < result < ht)) 1 0 1 reserved 1 1 0 reserved 1 1 1 reserved table 38-4. adcife interrupt group line line description related status 0 sequencer sequencer end of conversion (seoc) sequencer (last converted value) overrun (lovr) sequencer missed trigger event (smtrg) timing timer time-out window window monitor
1004 42023e?sam?07/2013 atsam4l8/l4/l2 38.7 user interface note: 1. the reset value for this register is device specific. refe r to the module configuration sect ion at the end of this chapt er. table 38-5. adcife register memory map offset register register name access reset 0x0000 control register cr write-only 0x00000000 0x0004 configuration regi ster cfg read/write 0x00000000 0x0008 status register sr read-only 0x00000000 0x000c status clear register scr write-only 0x00000000 0x0014 sequencer configuration register seqcfg read/write 0x00000000 0x0018 configuration direct memory access register cdma write-only 0x00000000 0x001c timing configuration register tim read/write 0x00000000 0x0020 internal timer register itimer read/write 0x00000000 0x0024 window monitor configuration register wcfg read/write 0x00000000 0x0028 window monitor threshold configuration register wth read/write 0x00000000 0x002c sequencer last converted value register lcv read-only 0x00000000 0x0030 interrupt enable register ier write-only 0x00000000 0x0034 interrupt disable register idr write-only 0x00000000 0x0038 interrupt mask register imr read-only 0x00000000 0x003c calibration register calib read/write 0x00000000 0x0040 version register version read-only - (1) 0x0044 parameter register parameter read-only - (1)
1005 42023e?sam?07/2013 atsam4l8/l4/l2 38.7.1 control register name: cr access type: write-only offset: 0x00 reset value: 0x00000000 writing a zero to any of those bits in this register has no effect. ? bgreqdis:bandgap buffer request disable writing a one to this bit disables the bandgap buffer request reading this bit always returns 0 ? bgreqen:bandgap buffer request enable writing a one to this bit enables the bandgap buffer request reading this bit always returns 0 ? dis:adcife disable writing a one to this bit disables the adcife reading this bit always returns 0 note: changes do not apply immediately, adcife status can be checked by reading the en field of the sr register ? en:adcife enable writing a one to this bit enables the adcife reading this bit always returns 0 note: changes do not apply immediately, adcife status can be checked by reading the en field of the sr register ? refbufdis: reference buffer disable writing a one to this bit disables the reference buffer reading this bit always returns 0 ? refbufen: reference buffer enable writing a one to this bit enables the reference buffer reading this bit always returns 0 ? strig:sequencer trigger writing a one to this bit generates a sequencer trigger event reading this bit always returns 0 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 - - - - bgreqdis bgreqen dis en 76543210 - - refbufdis refbufen strig tstart tstop swrst
1006 42023e?sam?07/2013 atsam4l8/l4/l2 ? tstart:internal timer start bit writing a one to this bit starts the internal timer reading this bit always returns 0 note: the internal timer status can be re ad in the runt field of the sr register ? tstop:internal timer stop bit writing a one to this bit stops the internal timer reading this bit always returns 0 note: the internal timer status can be re ad in the runt field of the sr register ? swrst: software reset writing a zero to this bit has no effect. writing a one to this bit resets the adcife, simulating a hardw are reset. using that control ensures that adcife internal features will return to their initial states . configuration registers won?t be affected.
1007 42023e?sam?07/2013 atsam4l8/l4/l2 38.7.2 configuration register name: cfg access type: read/write offset: 0x04 reset value: 0x00000000 ? prescal: prescaler rate slection ? clksel: clock selection for sequencer/adc cell 1: the apb clock is used 0: the generic clock is used 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 ----- prescal 76543210 - clksel speed refsel - prescal group configuration system clock division factor 000 div4 4 001 div8 8 010 div16 16 011 div32 32 100 div64 64 101 div128 128 110 div256 256 111 div512 512
1008 42023e?sam?07/2013 atsam4l8/l4/l2 ? speed: adc curren t reduction ? refsel: adc reference selection speed max speed 00 300 ksps 01 225 ksps 10 150 ksps 11 75 ksps refsel description 000 internal 1.0v (10/11*bandgap) 001 0.625*vcc 010 external reference 1 011 external reference 2 (dac_vout) 1xx vcc/2
1009 42023e?sam?07/2013 atsam4l8/l4/l2 38.7.3 status register name: sr access type: read-only offset: 0x08 reset value: 0x00000000 ? bgreq: bandgap buffer request status 1: bandgap buffer request is enabled 0: bandgap buffer request is disabled ? bgreqrefbuf: reference buffer status 1: reference buffer is enabled 0: reference buffer is disabled ? cbusy: conversion busy 1: adcife is converting 0: adcife is not converting ? sbusy: sequencer busy 1: adcife sequencer is running 0: adcife sequencer is ready ? tbusy: timer busy 1: adcife internal timer is running 0: adcife internal timer is stopped ? en: enable status 1: adcife is ready for operation 0: adcife is not ready ? tto: timer time-out this bit is set when the internal timer times out this bit is cleared when the corresponding bit in scr is written to one 31 30 29 28 27 26 25 24 - bgreq - refbuf cbusy sbusy tbusy en 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------- 76543210 - - tto - smtrg wm lovr seoc
1010 42023e?sam?07/2013 atsam4l8/l4/l2 ? smtrg:sequencer missed trigger event this bit is set when a sequencer trigger event is missed this bit is cleared when the corresponding bit in scr is written to one ? wm:window monitor this bit is set when the watched result value goes to the defined window this bit is cleared when the corresponding bit in scr is written to one ? lovr:sequencer last converted value overrun this bit is set when an overrun error occurs on the lcv register this bit is cleared when the corresponding bit in scr is written to one ? seoc:sequencer end of conversion this bit is set when an end of conversion occurs this bit is cleared when the corresponding bit in scr is written to one
1011 42023e?sam?07/2013 atsam4l8/l4/l2 38.7.4 status clear register name: scr access type: write-only offset: 0x0c reset value: 0x00000000 writing a zero to a bit in this register has no effect. writing a one to a bit clears the corresponding sr bit 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------- 76543210 - - tto - smtrg wm lovr seoc
1012 42023e?sam?07/2013 atsam4l8/l4/l2 38.7.5 sequencer conf iguration register name: seqcfg access type: read/write offset: 0x14 reset value: 0x00000000 4 31 30 29 28 27 26 25 24 - zoomrange - - - - 23 22 21 20 19 18 17 16 - muxneg muxpos 15 14 13 12 11 10 9 8 internal - res - trgsel 7654 3210 gcomp gain - bipolar - hwla
1013 42023e?sam?07/2013 atsam4l8/l4/l2 ? zoomrange: zoom shift/unipol ar reference source selection ? muxneg: mux selection on negative adc input channel ? muxpos: mux selection on positive adc input channel zoomrange mode comment 000 select vref for shift cycle all modes e xcept zoom and unipolar with hysteresis 001 select vdd/4 for shift cycle zoom mode 010 select vdd/2 for shift cycle zoom mode 011 select 3*vdd/4 for shift cycle zoom mode 1xx select 0.9*vref for shift cycle unipolar mode with hysteresis bipolar internal muxneg negative input to adc 0 0x xxx primary_anahot_xxx tied to ground 0 1x 001 or 111 pad ground 1 0x 000 primary_anahot_0 1 0x 001 primary_anahot_1 1 0x 010 primary_anahot_2 1 0x 011 primary_anahot_3 1 0x 100 primary_anahot_4 1 0x 101 primary_anahot_5 1 0x 110 primary_anahot_6 1 0x 111 primary_anahot_7 1 1x 000 vsingle = 0.9*vref 1 1x 001 pad ground 1 1x 010 vcalib3 = vref/10 1 1x 011 reference ground 1 1v 100 not used 1 1x 101 vcalib3 = vref/10 1 1x 110 not used 1 1x 111 pad ground bipolar internal muxpos positive input to adc x x0 0000 ad0 x x0 0001 ad1 x x0 0010 ad2 x x0 0011 ad3
1014 42023e?sam?07/2013 atsam4l8/l4/l2 x x0 0100 ad4 x x0 0101 ad5 x x0 0110 ad6 x x0 0111 ad7 x x0 1000 ad8 x x0 1001 ad9 x x0 1010 ad10 x x0 1011 ad11 x x0 1100 ad12 x x0 1101 ad13 x x0 1110 ad14 x x0 1111 bandgap x x1 x000 not used x x1 x001 bandgap x x1 x010 scaled vcc, vcc/10 x x1 x011 dac internal x x1 x100 not used x x1 x101 not used x x1 x110 vsingle = 0.9*vref x x1 x111 reference ground bipolar internal muxpos positive input to adc
1015 42023e?sam?07/2013 atsam4l8/l4/l2 ? internal: internal voltage sources selection ? res: resolution ? trgsel: trigger selection ? gcomp: gain compensation 1: enables the adc gain error reduction 0: disables the adc gain error reduction internal positive internal select ion negative internal selection 00 enables the primary/secondary voltage sources enables the primary voltage sources 01 enables the internal voltage sources enables the primary voltage sources 10 enables the primary/secondary voltage sources enables the internal voltage sources 11 enables the internal voltage sources enables the internal voltage sources res resolution 0 12-bits 18-bits trgsel trigger 000 software 001 internal adc timer 010 internal trigger source (refer to module configuration section) 011 continuous mode 100 external trigger pin rising edge 101 external trigger pin falling edge 110 external trigger pin both edges 111 reserved
1016 42023e?sam?07/2013 atsam4l8/l4/l2 ? gain: gain factor ? bipolar: bipolar mode 1: enables the differential mode 0: enables the single-ended mode ? hwla: half word left adjust 1: enables the hwla mode 0: disables the hwla mode gain gain factor 000 1 x 001 2 x 010 4 x 011 8 x 100 16 x 101 32 x 110 64 x 111 0,5 x
1017 42023e?sam?07/2013 atsam4l8/l4/l2 38.7.6 configuration direct memory access name: cdma access type: write-only offset: 0x18 reset value: 0x00000000 ? dw: double word transmitting number of dma transfer remainning to end the configuration of the next conversion ? tss: internal timer start or stop bit writing a one to this bit starts the internal timer writing a zero to this bit stops the internal timer ? dw: double word transmitting this bit must be set to zero (configuration completed) first dma word 31 30 29 28 27 26 25 24 dw zoomrange - --- 23 22 21 20 19 18 17 16 - muxneg muxpos 15 14 13 12 11 10 9 8 internal tss res - - - enstup 7654 3 210 gcomp gain strig bipolar - hwla second dma word (optional window mode) 31 30 29 28 27 26 25 24 dw - - - ht[11:8] 23 22 21 20 19 18 17 16 ht[7:0] 15 14 13 12 11 10 9 8 -wm lt[11:8] 76543210 lt[7:0]
1018 42023e?sam?07/2013 atsam4l8/l4/l2 this register is used for dma transfers to the adcife module . the first word transmitted is the general configuration. if the msb bit is set to one, a second word will be transfered to co mplete the configuration so that use the window mode. if the msb bit is set to zero, the configuration is completed. the second word is only used when the window mode is needed. in this case, its msb bit is always set to zero (configura- tion completed).
1019 42023e?sam?07/2013 atsam4l8/l4/l2 38.7.7 timing configuration register name: tim access type: read/write offset: 0x1c reset value: 0x00000000 ? enstup: enable startup 1: enables the startup time 0: disables the startup time ? startup: startup time number of clk_adc clock cycles to wait for starting conversion: (startup+1) 31 30 29 28 27 26 25 24 ----- --- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------enstup 76543210 - - - startup
1020 42023e?sam?07/2013 atsam4l8/l4/l2 38.7.8 internal timer register name: itimer access type: read/write offset: 0x20 reset value: 0x00000000 ? itmc:internal timer max counter f(itimer_timeout)=f(gclk)/(itmc+1) 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 itmc[15:8] 76543210 itmc[7:0]
1021 42023e?sam?07/2013 atsam4l8/l4/l2 38.7.9 window monitor configuration name: wcfg access type: read/write offset: 0x24 reset value: 0x00000000 ? wm: window monitor mode 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -wm- --- 76543210 -------- wm window monitor mode 000 off 001 mode 1: res(src) > lt 010 mode 2: res(src) < ht 011 mode 3: lt=res(src)) || (res(src)>=ht) 101 reserved 110 reserved 111 reserved
1022 42023e?sam?07/2013 atsam4l8/l4/l2 38.7.10 window monitor threshold configuration name: wth access type: read/write offset: 0x28 reset value: 0x00000000 ? ht:high threshold highthreshold value ? lt:low threshold low threshold value 31 30 29 28 27 26 25 24 ---- ht[11:8] 23 22 21 20 19 18 17 16 ht[7:0] 15 14 13 12 11 10 9 8 ---- lt[11:8] 76543210 lt [ 7 : 0 ]
1023 42023e?sam?07/2013 atsam4l8/l4/l2 38.7.11 sequencer last converted value name: lcv access type: read-only offset: 0x2c reset value: 0x00000000 ? lcnc: last converted negative channel this field is set by hardware to the last negative channel converted, i.e. what negat ive channel the lcv represents. ? lcpc: last converted positive channel this field is set by hardware to the last positive channel converted, i.e. what positive channel the lcv represents. ? lcv: last converted value this field is set by hardware to the last sequencer converted value depending on precision and on the choosen left adjustment mode (seqcfg.hwla). 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 - lcnc lcpc 15 14 13 12 11 10 9 8 lcv[15:0] 76543210 lcv[7:0]
1024 42023e?sam?07/2013 atsam4l8/l4/l2 38.7.12 interrupt enable register name: ier access type: write-only offset: 0x30 reset value: 0x00000000 writing a zero to a bit in this register has no effect. writing a one to a bit in this register will set the corresponding bit in imr. 31 30 29 28 27 26 25 24 ------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 ------- 76543210 - - tto - smtrg wm lovr seoc
1025 42023e?sam?07/2013 atsam4l8/l4/l2 38.7.13 interrupt disable register name: idr access type: write-only offset: 0x34 reset value: 0x00000000 writing a zero to a bit in this register has no effect. writing a one to a bit in this register will clear the corresponding bit in imr. 31 30 29 28 27 26 25 24 ------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 ------- 76543210 - - tto - smtrg wm lovr seoc
1026 42023e?sam?07/2013 atsam4l8/l4/l2 38.7.14 interrupt mask register name: imr access type: read-only offset: 0x38 reset value: 0x00000000 0: the corresponding interrupt is disabled. 1: the corresponding interrupt is enabled. a bit in this register is cleared when the corresponding bit in idr is written to one. a bit in this register is set when the corresponding bit in ier is written to one. 31 30 29 28 27 26 25 24 --- --- 23 22 21 20 19 18 17 16 ---- --- 15 14 13 12 11 10 9 8 --- --- 76543210 - - tto - smtrg wm lovr seoc
1027 42023e?sam?07/2013 atsam4l8/l4/l2 38.7.15 calibration register name: calib access type: read/write offset: 0x3c reset value: 0x00000000 ? fcd: flash calibration done set to one when calib and biascal have been updated by the flash fuses after a reset. 1: the flash calibration will be redone after any reset 0: the flash calibration will only be redone after a power-on reset ? biascal: bias calibration ? biassel: select bias mode 1: select bandgap bias 0: select mixed bias 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------fcd 15 14 13 12 11 10 9 8 biascal - - - biassel 76543210 calib biascal ptat current bgap current total current 0000 3.0 1.1 4.1 0001 3.0+0.75 1.1 4.85 0010 default setting 3.0+1.5 1.1 5.6 0011 3.0+1.5+0.75 1.1 6.35 0100 3.0 1.1+1.1 5.2 0101 3.0+0.75 1.1+1.1 5.95 0110 3.0+1.5 1.1+1.1 6.7 0111 3.0+1.5+0.7 1.1+1.1 7.45 10xx pure bandgap bias 0 5.5 5.5 11xx 0 5.5+1.1 6.6
1028 42023e?sam?07/2013 atsam4l8/l4/l2 ? calib: calibration value calib value description 7s1 msb 4 s1 lsb 3s2 msb 0 s2 lsb
1029 42023e?sam?07/2013 atsam4l8/l4/l2 38.7.16 module version name: version access type: read-only offset: 0x40 reset value: - ? variant: variant number reserved. no functionality associated. ? version: version number version number of the module. no functionality associated. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 ---- variant 15 14 13 12 11 10 9 8 ---- version[11:8] 76543210 version[7:0]
1030 42023e?sam?07/2013 atsam4l8/l4/l2 38.7.17 parameter register name: parameter access type: read-only offset: 0x44 reset value: - ? n: number of channels 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------- 76543210 n
1031 42023e?sam?07/2013 atsam4l8/l4/l2 38.8 module configuration the specific configuration for each adcife inst ance is listed in the following tables.the module bus clocks listed here are connected to the system bus clocks. refer to section 10. ?power man- ager (pm)? on page 108 for details. table 38-6. adcife configuration feature adcife external ref 2 connection dacc out output table 38-7. adcife clock name clock name description clk_adcife clock for the adcife bus interface gclk_adcife the generic clock used for the adcife is gclk10 register reset value version 0x00000100
1032 42023e?sam?07/2013 atsam4l8/l4/l2 39. lcd controller (lcdca) rev: 1.0.0.0 39.1 features ? display capacity up to 40 segment and up to 4 common terminals ? supports from static up to 1/4 duty ? supports static and 1/3 bias ? shadow display memory gives fu ll freedom in segment update ? ascii character mapping ? automated characters string scrolling ? automated characters string display ? automated segm ents display ? autonomous animatio n up to 8 segments ? lcd driver active in power save mode for low power operation ? low power waveform ? flexible selection of frame frequency ? configurable blink mode and frequency ? uses only 32 khz clock ? on-chip lcd power supply ? software contrast adjustment control ? equal source and sink capabi lity to increase lcd life time ? interrupt mode for display update or wake-up from sleep mode 39.2 overview a lcd display is made of several segments (or co mplete symbols) which can be visible or invis- ible. a segment has two electrodes with liquid crystal between them. these electrodes are the common terminal (com) and the segment terminal (seg). when a voltage above a threshold voltage is applied across the liquid crystal, the segment becomes visible. the voltage must alter- nate to avoid an electrophoresis effect in the li quid crystal, this effect degrades the display. hence the voltage waveform across a segment must not have a dc-component. figure 39-1. lcd segment/common terminals the lcd controller (lcdca) is intended for m onochrome passive liquid crystal display (lcd) with up to 4 common terminals and up to 40 segment terminals. u nused segment/common ter- minals (pins) are configured as general purpos e i/o pins.the lcd controller uses a 32khz clock (clk_lcd) and can therefore be running in deep sleep modes. s egm e nt 0 se gm en t 1 s egment 2 seg me nt 4 2 s egme n t 41 se gm e n t 40 com0 com1 seg0 seg1 seg2 ... ...
1033 42023e?sam?07/2013 atsam4l8/l4/l2 dedicated low power waveform, contrast control, extended interrupt mode, ascii character mapping, automated modes... are defined to offload the cpu, reduce interrupts and reduce power consumption. to reduce hardware design complexity, the m odule includes integrated lcd buffers, an inte- grated power supply voltage. 39.3 block diagram figure 39-2. lcdca block diagram 39.4 i/o lines description 39.5 product dependencies in order to use this module, other parts of the system must be configured correctly, as described below. lcdca analog switch array shadow display memory display memory timing lcd power supply automated modes apb interface segx comy vlcd biash biasl capl caph irq bpm clk32 table 39-1. i/o lines description pin name pin description type segx segment terminal x analog comy common terminal y analog vlcd bias voltage analog bias1 bias voltage (= 1/3 v lcd )analog bias2 bias voltage (= 2/3 v lcd )analog capl high voltage end of flying capacitor analog caph low voltage end of flying capacitor analog
1034 42023e?sam?07/2013 atsam4l8/l4/l2 39.5.1 i/o lines the lcdca pins (segx and comy) are multiplexed with other peripherals. the user must first configure the i/o controller to give control of the pins to the lcdca. vlcd, bias1, bias2, capl, caph are not multiplexed. 39.5.2 power management this module can control the lcd display while clk_lcdca is disabled but stops functioning when clk_lcd (32khz) is disabled. the power consumption of lcdca itself can be minimized by: ? using the lowest acceptable frame rate (refer to the lcd glass technical characteristics), ? using the low power waveform (default mode), ? using automated modes, ? configuring the lowest possible contrast value. 39.5.3 clocks the clock for this module (clk_lcdca) is generated by the power manager. it can be enabled or disabled either manually through the user interface of the power manager or automatically when the system enters a sleep mode that disa bles the clocks to the peripheral bus modules. the 32khz clock (clk_lcd) must be enabled before use. when system enters a sleep mode, 32khz clock can be disabled, see power manager chapter for details. 39.5.4 interrupts the lcdca interrupt request line is connected to the interrupt controller. using the interrupt requires the interrupt controller to be configured first. 39.5.5 wake up wake up signal is connected to power manager (pm). using wake up mechanism requires the pm to enable the corresponding asynchronous wake up source first. also lcdca interrupt must be enabled first. 39.5.6 debug operation when an external debugger forces the cpu into debug mode, the lcdca continues normal operation. 39.6 functional description 39.6.1 lcd display the display memory stores the values of all segments to display. accessible through apb, it should be filled befor e next frame starts. a start of a new frame triggers the update of the shadow display memory. the content of display memory is copied into the shadow display memory. a display memory refresh is possible without affecting data that is sent to the panel. note that display memory is not initialized at power-up. when a bit in the display memory is written to one, the corres ponding segment will be energized (on / opaque), and de-energized (off / transparent) when this bit is written to zero.
1035 42023e?sam?07/2013 atsam4l8/l4/l2 addressing com0 starts a frame by driving an opposite phase with large amplitude on com0 as against non addressed com terminals. non-energized segments are in phase with the addressed com0, and energized segments have opposite phase and large amplitude (refer to ?operating modes? on page 1035 ). shadow display memory bits are multiplexed into the decoder. the decoder is configured by the lcd timing and controls the analog switches to produce an output waveform onto each selected com terminals (duty value). figure 39-3. display memory mapping 39.6.2 operating modes to energize a segment, an absolute voltage above the lcd threshold must be applied. this is done by setting the seg terminal to opposite phase when the corresponding com terminal is active. for a display with more than one common terminal, two additional voltage levels (1/3 bias) must be applied. otherwise, non-energized segments on com0 would be energized for all non-selected common lines. duty bits (duty) in the configuration regist er (cfg) defines the duty cycle. unused common terminals are driven to ground. 39.6.2.1 static duty and static bias if all segments on a lcd have one common electrode then each segment have a unique seg- ment terminal. seg0-com0 is the voltage across a segment that is on and seg1-com0 is the voltage across a segment that is off. com0 com1 com2 com3 offset 0 1 2 3 4 5 6 7 8 9 15 19 data[39:0] data[39:0] data[39:0] 10 0 71 2 3 4 5 6 data[39:0] table 39-2. duty selection duty[1:0] duty bias com pins used 0 0 1/4 1/3 com[0:3] 0 1 static static com0 1 0 1/2 1/3 com[0:1] 1 1 1/3 1/3 com[0:2]
1036 42023e?sam?07/2013 atsam4l8/l4/l2 figure 39-4. driving a lcd with one common line 39.6.2.2 1/2 duty and 1/3 bias for a lcd with two common terminals (1/2 duty) a more complex waveform must be used to individually control segments. seg0-com0 is the voltage across a segment that is on and seg0-com1 is the voltage across a segment that is off. figure 39-5. driving an lcd with two common lines 39.6.2.3 1/3 duty and 1/3 bias 1/3 bias is usually recommended for lcd with three common terminals (1/3 duty). seg0-com0 is the voltage across a segment that is on and seg0-com1 is the voltage across a segment that is off.
1037 42023e?sam?07/2013 atsam4l8/l4/l2 figure 39-6. driving a lcd with three common lines 39.6.2.4 1/4 duty and 1/3 bias 1/3 bias is optimal for lcd with four common terminals (1/4 duty). seg0-com0 is the voltage across a segment that is on and seg0-com1 is the voltage across a segment that is off. figure 39-7. driving a lcd with four common lines 39.6.3 enabling/disabling lcdca write bit enable (en) to one in control register (cr) to enab le the module. write bit disable (dis) to one to disable it. lcd controller will be di sabled after the comple tion of current frame. bit enable in status register (sr.en) is set to one when lcd controller is ready to operate and set to zero when lcd power supply is off. seg0-com0 frame frame v lcd seg0 com0 2/3 v lcd gnd 1/3 v lcd v lcd 2/3 v lcd gnd 1/3 v lcd v lcd 2/3 v lcd gnd 1/3 v lcd -1/3 v lcd -2/3 v lcd -v lcd frame frame v lcd seg0 com1 2/3 v lcd gnd 1/3 v lcd v lcd 2/3 v lcd gnd 1/3 v lcd v lcd 2/3 v lcd gnd 1/3 v lcd -1/3 v lcd -2/3 v lcd -v lcd seg0-com1
1038 42023e?sam?07/2013 atsam4l8/l4/l2 when lcd controller is disabled all segment and common terminals are driven to gnd, dis- charging the lcd in order to avoid dc voltage across the segments and a slowly fading image. data in the display memory is preserved. in order to restart correctly, it is preferrable to disable all functions (blinking, fcx,...) before dis- abling lcd controller. 39.6.4 waveform modes to reduce toggle activity and hence power consumption, write a zero to the waveform mode (cfg.wmod) to enable the low power waveform mode (the lcd glass must support this mode). the low power waveform period is then twice the standard waveform period, in both modes dc voltage is null. to select the standard waveform, write a one to the cfg.wmod bit. this bit shall not be modi- fied when lcdca is enabled. figure 39-8. waveform modes (three common lines) 39.6.5 timing generation 39.6.5.1 frame rate the prescaler field (presc) in timing register (tim) selects a tap point from a ripple counter. the ripple counter output can be further divi ded by setting the clock divider (clkdiv[2:0]). v lcd 2/3 v lcd 1/3 v lcd gnd gnd v lcd 2/3 v lcd 1/3 v lcd gnd v lcd 2/3 v lcd 1/3 v lcd -1/3 v lcd -2/3 v lcd -v lcd frame 1 frame 2 standard waveform v threshold -v threshold seg0-com0 com0 seg0 v lcd 2/3 v lcd 1/3 v lcd gnd gnd v lcd 2/3 v lcd 1/3 v lcd gnd v lcd 2/3 v lcd 1/3 v lcd -1/3 v lcd -2/3 v lcd -v lcd frame 1 low power waveform v threshold -v threshold seg0-com0 com0 seg0 t = 20ms t = 40ms table 39-3. lcd prescaler selection presc output from prescaler 0 clk_lcd / 8 1 clk_lcd / 16
1039 42023e?sam?07/2013 atsam4l8/l4/l2 the clock division field (clkdiv) in tim register defines the division ratio in the clock divider. this gives extra flexibility in frame rate setting. where: n = prescaler divider (8 or 16). k = 8 for 1/4, 1/2 and static duty. k = 6 for 1/3 duty. wmod = 0 in low power waveform mode, = 1 in standard waveform mode. note that when using 1/3 duty, the frame rate is increased by 33% compared to the values listed above and in low power waveform mode, the frame rate is divided by two. 39.6.5.2 frame counters for several functions (blinking, automated modes,...) a frame counter is used to create a time base. there are three independent frame counter s (fc0, fc1 and fc2) which can be associ- ated to any function (refer to corresponding section). for fc0 only, the prescaler of 8 can be bypassed by writting a one to tim.fc0pb. note that frame counter frequency depends on frame duration therefore of waveform mode. table 39-4. lcd clock divider (1/4 duty, wmod=1) clkdiv[2:0] divided by frame rate (1/4 duty) f(clk_lcd) = 32 khz f(clk_lcd) = 32768 hz n=8 n=16 n=8 n=16 0 0 0 1 500 hz 250 hz 512 hz 256 hz 0 0 1 2 250 hz 125 hz 256 hz 128 hz 0 1 0 3 166.667 hz 83.333 hz 170.667 hz 85.333 hz 0 1 1 4 125 hz 62.5 hz 128 hz 64 hz 1 0 0 5 100 hz 50 hz 102.4 hz 51.2 hz 1 0 1 6 83.333 hz 41.667 hz 85.333 hz 42.667 hz 1 1 0 7 71.429 hz 35.714 hz 73.143 hz 36.671 hz 1 1 1 8 62.5 hz 31.25 hz 64 hz 32 hz table 39-5. frame rate examples (wmod=1) clk_lcd duty k presc n clkdiv[2:0] frame rate 32.768 khz static 8 1 16 4 32768 / (8*16*(1+4)) = 51.2 hz 32.768 khz 1/2 8 1 16 4 32768 / (8*16*(1+4)) = 51.2 hz 32.768 khz 1/3 6 1 16 4 32768 / (6*16*(1+4)) = 68.267 hz 32.768 khz 1/4 8 1 16 4 32768 / (8*16*(1+4)) = 51.2 hz framerate f clk_lcd () kn 1 clkdiv + () 2 1 wmod ? () () --------------------------------------------------------------------------------------------------- - = f fcx framerate tim.fcx 8 () 1 + ---------------------------------------------- - =
1040 42023e?sam?07/2013 atsam4l8/l4/l2 each frame counter is enabled by writing a one to frame counter x enable (cr.fcxen) and disabled by writing a one to frame counter x disable (cr.fcxdis).frame counter must be dis- abled (sr.fcxs=0) before the update of its associated tim.fcx value. 39.6.6 cpu display memory access 39.6.6.1 direct access cpu can access display memory in direct access by writing to data register low x (drlx) and data register high x (drhx). read-modify-write operation is then required to update few bits. to modify a segment defined by segx / comy, select register r and bit b: where r is the register index in the list {drl0, drh0, drl1, drh1, drl2, drh2, drl3, drh3} and b is the bit position in this register. 39.6.6.2 indirect access cpu can also update up to 8 bits in display memo ry in indirect access by writing to indirect access data register (ia dr). it allows to modify 1 up to 8 bi ts in a single operation without mod- ifying masked bits in display memory (no read-modify-write operation). this register requires: ? data[7:0], each bit represents the state of a segment, ? dmask[7:0], each bit is a mask for data fiel d. when dmask[x]=1, data[x ] is not written to display memory, ? off[4:0], byte offset in display memory (see figure 39-3 on page 1035 ). to modify a segment defined by segx / comy, write byte at offset off, bit b: 39.6.7 locking shadow display memory writing a one to lock bit, in configuration register (cfg), freezes the shadow display memory update. then if the display memory is modified, the display remains unchanged. when this bit is cleared, the shadow display memory is updated when a new frame starts. 39.6.8 blinking modes 39.6.8.1 software blinking writing bit blank in cfg register to one turns off all lcd segments at the next frame. if blank=0 the content of the display memory is output on the lcd. the blink frequency is then software dependant. to avoid unexpected intermediate display, blank command should be writ- ten after the end of the frame (sr.fc0r=1). lcd controller must be running (frames are generated) to blink segments. 39.6.8.2 hardware blinking to blink all segments on lcd panel, write a zero to blink mode (mode) in blink configuration register (bcfg). write a one to mode to blink selected segments. ry << 6x) >> 5 + ( = bx & 0x1f = off 5(y << 3) x) >> 3 + ( = bx & 0x7 =
1041 42023e?sam?07/2013 atsam4l8/l4/l2 up to eight segments can be selected individually to blink. each bit in blink segment selection x field (bcfg.bssx) selects a segment for blin king. if bss0[y]=1, segment connected to seg0/comy is selected to blink. if bss1[y]=1, segment connected to seg1/comy is selected to blink. a segment will blink if its corres ponding bit is o ne in the display memory , otherwise it remains off. the blink frequency is defined by the number of frames (fcx in tim register) between each state on/off. so after fcx+1 frames, the segment will change state. note that blinking fre- quency is also related to waveform mode, see ?waveform modes? on page 1038 . the frame counter is selected by writing its number in bcfg.fcs field. bcfg.bssx and bcfg.mode should be modified after a frame has ended (sr.fc0r=1), bcfg.fcs shall not be modified when blinking is running. the blinking is started by writing a one to cr.bstart and stopped by writing a one to cr.bstop. the status of blinking can be read in sr.blks. 39.6.9 autonomous segment animation up to eight pixels can be animated by an internal circular shift register. up to eight states are then defined to make a running wheel for example. the number of segments used for animation must be written in size field in circular shift register configuration (csrcfg). if size=n, cir- cular shift register uses bits 0 to n-1. the circular shift register bits are mapped on seg2 and seg3 of all common terminals. table 39-6. blinking modes blank en bss1[3:0] bss0[3:0] comment 1 x xxxx xxxx all segments are off 0 0 xxxx xxxx all segments are driven by the display memory 01 0000 0000 all segments are blinking at the blink frequency not equal to zero selected segment(s) are blinking at the blink frequency table 39-7. circular shift register bit mapping shift register bit com seg 002 103 212 313 422 523 632 733
1042 42023e?sam?07/2013 atsam4l8/l4/l2 the shifting period is defined by the number of frame in tim.fcx. the frame counter is selected by writing its number in csrcfg .fcs field. if frame rate is 50hz (20ms) in standard waveform mode, shifting period is 160ms up to 5.1s. initial value of circular shift register must be written in csrcfg.data, the direction is defined by csrcfg.dir bit (0 for left, 1 for right) and circular shift register operation is started by writing a one to cr.cstart. once enabled, data is shifted every tim.fcx+1 fram es, circular shift register is autonomous and system can enter any sleep mode (only 32khz must be running). figure 39-9. wheel animation example (8 segments) 39.6.10 ascii character mapping lcdca handles up to four ascii characters tables, co nfigured in characte r mapping configura- tion register (cmcfg). instead of handling each segments in display memory for a selected digit, user writes ascii code in character mapping control register (cmcr) to display the cor- responding character. user can then drive several digits with few operations: 1. select the type of digit (cmcfg.tdg), see figure 39-10 on page 1043 , 2. write the start segment value (cmcfg.stseg) of the first digit, 3. select digit reverse mode (cmcfg.drev) if required. if drev is one, segment index is decremented, 4. then write ascii code in cmcr register. if digit uses contiguous segments, repeat step 4 to update remaining digits. segment index is updated automatically according to the number of segment used in the digit and drev value. 0 0 1 0 0 0 0 0 circular shift register lcd wheel b0 b1 b7 b6 b5 b4 b3 b2
1043 42023e?sam?07/2013 atsam4l8/l4/l2 figure 39-10. type of digit supported character mapping saves cpu execution time and allows a fast return to sleep mode after dis- play update. 7-segment - 4 com term . - 2 seg term . 7-segment - 3 com term . - 3 seg term . 16-segment - 3 com term . - 6 seg term . 14-segment - 4 com term . - 4 seg term .
1044 42023e?sam?07/2013 atsam4l8/l4/l2 table 39-8. 7-segments character table
1045 42023e?sam?07/2013 atsam4l8/l4/l2 table 39-9. 14-segments character table
1046 42023e?sam?07/2013 atsam4l8/l4/l2 table 39-10. 16-segments character table
1047 42023e?sam?07/2013 atsam4l8/l4/l2 39.6.11 automated character mapping displaying predefined character strings can be automated using the peripheral dma controller (pdca). two modes are available, defined by mode bit in automated character mapping con- figuration register (acmcfg): ? mode=0, the sequential character string display mode is selected ? mode=1, the scrolling of character string display mode is selected 39.6.11.1 sequential characters string display this mode displays characters of a string periodically (frame basis). the configuration is: ? specify the number of digits to display (acmcfg.dign), ? specify the type of digit (acmcfg.tdg), see ?ascii character mapping? on page 1042 , ? specify the start segment (acmcfg.stseg) of the first character of the string, ? select the digit reverse mode (acmcfg.drev) if required. this mode is useful if digits have been inverted on the glass (first digit on the right), ? set the display period by writing the number of frame between each display in frame counter x in tim register (tim.fcx), ? select a frame counter by writ ing its number in acmcfg.fcs, ? enable this mode by writing a one to the acmcfg.en bit, ? configure pdca to transfer an ascii character string of any size (should a multiple of the number of digit). to repeat the character string display, repeat the pdca transfer. tim.fcx defines the number of frames between each pdca transfer (display update). if frame rate is 50hz (20ms) in standard waveform mode, characters are displayed with a period from 160ms up to 5.1s. nframes 8 fcx 1 + () =
1048 42023e?sam?07/2013 atsam4l8/l4/l2 figure 39-11. sequential character string example (dign = 5, frame rate = 50hz, tim.acmfc = 31) 39.6.11.2 scrolling of characters string this mode displays the same characters string periodically shifted by one character in left direc- tion. the configuration is: ? specify the number of digit (acmcfg.dign), ? specify the number of scrolling steps ac mcfg.steps = string length - dign + 1, ? specify the type of digit (acmcfg.tdg), see ?ascii character mapping? on page 1042 , ? specify the start segment (acmcfg.stseg) of the first character to display ? select the digit reverse mode (acmcfg.drev). if enabled acmcfg.stseg must be initialized with the start segment corresponding to the last character on the lcd glass. ? set the display period by writing the number of frame in frame counter x (tim.fcx), ? select a frame counter by writ ing its number in acmcfg.fcs, ? enable this mode by writing a one to the acmcfg.en bit, ? configure pdca to transfer the ascii characters string to the automated character mapping data register (acmdr). pdca must be configured to repeat transfer in order to scroll h e l w o r t h i string = ?helloworldthi s is automated ? l l s o d i s a u t o m a t e d 0 5.1 10.2 15.3 20.4 25.5 t (s)
1049 42023e?sam?07/2013 atsam4l8/l4/l2 character string. number of tr ansfer must be a multiple of steps to get a co mplete scrolling of the string. blank characters can be added to string to create a complete scrolling. the frame counter selected (tim.fcx) defines the number of frames between each pdca trans- fer, refer to ?sequential characters string display? on page 1047 figure 39-12. characters string scro lling examples (dign = 3) 39.6.12 automated bit mapping any segment can be modified using the peripheral dma controller, making predefined anima- tions possible. data can be located in flash or ram and are transferred periodically to the display memory. when pdca writes to the automated bit mapping data register (abmdr), up to 8 segments can be modified. pdca must be configured to transfer a word made of: ? data[7:0], each bit represents the state of a segment, string=?hello? (string length=5, steps=3) h e l e l l string=?hello ? (string length=8, steps=6) l l o l o o h e l h e l e l l l l o h e l 1 2 3 1 2 3 1 step 1 2 3 4 5 6 1 e l l l l o h e l
1050 42023e?sam?07/2013 atsam4l8/l4/l2 ? dmask[7:0], each bit is a mask for data fiel d. when dmask[x]=1, data[x ] is not written to display memory, ? off[4:0], byte offset in display memory (see figure 39-3 on page 1035 ). to update more than 8 segments, pdca must transfer multiple words before shadow memory is updated. this number of words must also be written in size field in automated bit mapping configuration register (abmcfg), it indicates the number of writes in display memory to form a frame. to make an automated animation of n states with m segments, pdca must be configured to transfer n x size (= m/8 or more) words. note that if segments are at any position in display memory, dmask is used then pdca size can be up to n x m. the display period (animation update) is defined by writing the number of frame in tim.fcx. the frame counter is selected by wr iting its number in abmcfg.fcs. animation can be repeated if pdca is configured to repeat the whole transfer. 39.6.13 contrast adjustment contrast is defined by the maximum value of v lcd . the higher value the higher contrast. fine contrast value (fcst) in cfg register is a signed value (two?s complement) which defines the maximum voltage v lcd on segment and common terminals. new value takes effect at the beginning of next frame. 39.6.14 interrupts lcdca can generate an interrupt at the beginning of a frame. when frame coun ter 0 rollover bit (sr.fc0r) is set to one and interrupt is not masked, lcdca interrupt is pending. moreover frame counter 0 (tim.fc0) can be used to select the interrupt period generation. this mode can provide a useful time base to update lcd. if tim.fc0pb=0: if tim.fc0pb=1: note that in low power waveform mode, frame period is twice the frame period in standard wave- form mode. an interrupt request will be generated if the corresponding bit in the interrupt mask register (imr) is set. bits in imr are set by writing a one to the corresponding bit in the interrupt enable register (ier) and cleared by writing a one to the corresponding bit in the interrupt disable reg- ister (idr). the interrupt request remains active until the corresponding bit in sr is cleared by writing a one to the corresponding bit in status clear register (scr). 39.6.15 lcd wake up lcd controller can wake up cpu with the interrupt request line. but in sleep modes where apb clocks are off, lcd wake up mechanism must be enabled to wake up cpu. v lcd 3 vfcst ( + 0 016 v ,) = interrupt period tim.fc0 8 () 1 + () frame period = interrupt period tim.fc0 1 + () frame period =
1051 42023e?sam?07/2013 atsam4l8/l4/l2 wake up mechanism is enabled by writing a one to the wake up enable (wen) bit in configura- tion register. it is disabled by writing a one to the wake up disable bit (wdis). moreover lcdca interrupt request must not be masked (see previous section) and lcdca bit in asynchronous wake up enable register (awen.lcdca) must be set to one (see power manager chapter). wake up signal is generated when frame counter 0 rolls over. when wake up is detected in power manager, system clocks are running therefore sr.fc0r is set to one and lcdca irq is generated. cpu is then woken up. wake up signal is cleared by disabling wake up mechanism. 39.6.16 lcd power supply to operate correctly, lcd controller requires a reference level. the external bias bit (xbias) in cfg register selects the source of v lcd . if xbias is zero, v lcd sources voltages from the inter- nal bandgap reference. otherwise, v lcd must be powered externally. note that when using external v lcd , the fine contrast controlled by cfg.fcst is inoperative. figure 39-13. lcd power supply block diagram table 39-11. lcd power supply pins sr.en cfg.xbias vlcd bias2 bias1 caph / capl 0 x h.z. h.z. h.z. h.z. 1 0v lcd 2/3 v lcd (also in static mode) 1/3 v lcd (also in static mode) capacitor pump charge 1 input for vlcd - input for bias2 - h.z. if static bias - input for bias1 - h.z. if static bias h.z. bias1 bias2 v lcd capl caph comy segx xbias x3 x2 x1 bandgap reference pump contrast
1052 42023e?sam?07/2013 atsam4l8/l4/l2 figure 39-14. internal and external bias generation device vcc vcc caph capl vlcd biash biasl gnd internal generation (static or 1/3 bias) 100 nf 100 nf 100 nf 100 nf device vcc vcc caph capl vlcd biash biasl gnd external generation (static) ext. vlcd decoupling capacitor device vcc vcc caph capl vlcd biash biasl gnd external generation (example) (1/3 bias) ext. vlcd decoupling capacitors (1) (1) (1) (1) (2) (1) values are given for design guidance only. (2) bias generation can be provided by other voltage source than a divison resistor
1053 42023e?sam?07/2013 atsam4l8/l4/l2 39.7 user interface note: 1. the reset value for this register is device specific. please refer to the module configuration section at the end of thi s chapter. table 39-12. lcdca register memory map offset register register name access reset 0x00 control register cr write-only - 0x04 configuration register cfg read/write 0x00000000 0x08 timing register tim read/write 0x00000000 0x0c status register sr read-only 0x00000000 0x10 status clear register scr write-only - 0x14 data register low 0 drl0 read/write - 0x18 data register high 0 drh0 read/write - 0x1c data register low 1 drl1 read/write - 0x20 data register high 1 drh1 read/write - 0x24 data register low 2 drl2 read/write - 0x28 data register high 2 drh2 read/write - 0x2c data register low 3 drl3 read/write - 0x30 data register high 3 drh3 read/write - 0x34 indirect access data register iadr write-only - 0x38 blink configuration register bcfg read/write 0x00000000 0x3c circular shift register confi guration csrcfg read/write 0x00000000 0x40 character mapping configuration register cmcfg read/write 0x00000000 0x44 character mapping data register cmdr write-only - 0x48 automated character mapping configur ation register acmcfg read/write 0x00000000 0x4c automated character mapping data register acmdr write-only - 0x50 automated bit mapping configurat ion register abmcfg read/write 0x00000000 0x54 automated bit mapping da ta register abmdr write-only - 0x58 interrupt enable register ier write-only - 0x5c interrupt disable register idr write-only - 0x60 interrupt mask register imr read-only 0x00000000 0x64 version register version read-only - (1)
1054 42023e?sam?07/2013 atsam4l8/l4/l2 39.7.1 control register name: cr access type: write-only offset: 0x00 reset value: - writing a zero to a bit in this register has no effect. ? cstop: circular shift stop writing a one to this bit stops circular shift register. ? cstart: circular shift start writing a one to this bit starts circular shift register. ? bstop: blinking stop writing a one to this bit stops blinking. ? bstart: blinking start writing a one to this bit starts blinking. ? wen: wake up enable writing a one to this bit enables wake up mechanism. ? wdis: wake up disable writing a one to this bit disables wake up mechanism. ? cdm: clear display memory writing a one to this bit clears immediately the display memory. ? fc2en: frame counter 2 enable writing a one to this bit enables the frame counter 2. ? fc2dis: frame counter 2 disable writing a one to this bit disables the frame counter 2. ? fc1en: frame counter 1 enable writing a one to this bit enables the frame counter 1. ? fc1dis: frame counter 1 disable writing a one to this bit disables the frame counter 1. ? fc0en: frame counter 0 enable writing a one to this bit enables the frame counter 0. ? fc0dis: frame counter 0 disable writing a one to this bit disables the frame counter 0. ? en: enable writing a one to this bit enables the lcd controller. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 - cstop cstart bstop bstart wen wdis cdm 76543210 fc2en fc2dis fc1en fc1dis fc0en fc0dis en dis
1055 42023e?sam?07/2013 atsam4l8/l4/l2 ?dis: disable writing a one to this bit disables the lcd controller.
1056 42023e?sam?07/2013 atsam4l8/l4/l2 39.7.2 configuration register name: cfg access type: read/write offset: 0x04 reset value: 0x00000000 nsu, duty, wmod and xbias shall not be modified when lcdca is enabled (sr.en=1). ? nsu: number of segment terminals in use this field indicates the number of segment terminals in use. it prevents any activity on mu xes driving the unused segment terminals. ? fcst: fine contrast defines the maximum voltage v lcd on segment and common terminals. fcst is a signed number (two's complement). new value takes effect at the beginning of next frame. v lcd = 3.0 v + (fcst[5:0] * 0.016 v) ? duty: duty select this field defines the duty cycle. ? lock: lock 0: shadow display memory is unlocked. 1: shadow display memory is locked and can?t be updated. ? blank: blank lcd 0: lcd segments value is defined in shadow display memory. 1: turns off all lcd segments. ? wmod: waveform mode 0: low power waveform mode. 1: standard waveform mode. 31 30 29 28 27 26 25 24 -- nsu 23 22 21 20 19 18 17 16 -- fcst 15 14 13 12 11 10 9 8 ------ duty 76543210 ----lockblankwmodxbias table 39-13. duty selection duty[1:0] duty bias com pins used 0 0 1/4 1/3 com[0:3] 0 1 static static com0 1 0 1/2 1/3 com[0:1] 1 1 1/3 1/3 com[0:2]
1057 42023e?sam?07/2013 atsam4l8/l4/l2 if this bit is modified during display operation the waveform mode is applied at the beginning of next frame. ? xbias: external bias generation 0:internal bias is used. 1:external bias is used.
1058 42023e?sam?07/2013 atsam4l8/l4/l2 39.7.3 timing register name: tim access type: read/write offset: 0x08 reset value: 0x00000000 clkdiv and presc shall not be modified when lcd controller is enabled. fcx shall not be modified when frame counter x is enabled. ? fc2: frame counter 2 number of frame before rollover = ((fc2 * 8) + 1). ? fc1: frame counter 1 number of frame before rollover = ((fc1 * 8) + 1). ? fc0pb: frame counter 0 prescaler bypass 0: fc prescaler is not bypassed 1: fc prescaler is bypassed ? fc0: frame counter 0 number of frame before rollover = ((fc0 * 8) + 1) if fc0pb=0 else (fc0 + 1). ? clkdiv: lcd clock division defines the lcd frame rate. k = 8 for 1/4, 1/2 and static duty. k = 6 for 1/3 duty. ? presc: lcd prescaler select 0: n = 8 1: n = 16 31 30 29 28 27 26 25 24 --- fc2 23 22 21 20 19 18 17 16 --- fc1 15 14 13 12 11 10 9 8 --fc0pb fc0 76543210 ---- clkdiv presc framerate fclk lcd () kn 1 clkdiv + () 2 1 wmod ? () () --------------------------------------------------------------------------------------------------- - =
1059 42023e?sam?07/2013 atsam4l8/l4/l2 39.7.4 status register name: sr access type: read-only offset: 0x0c reset value: 0x00000000 ? cps: charge pump status 0: charge pump is inactive or not ready. 1: charge pump is ready. ? csrs: circular shift register status 0: csr is not running. 1: csr is running. ? blks: blink status 0: blinking is not running. 1: blinking is running. ? wen: wake up status 0: wake up mechanism is disabled. 1: wake up mechanism is enabled. ? en: lcdca status 0: lcd controller is disabled. 1: lcd controller is enabled. ? fc2s: frame counter 2 status 0: frame counter 2 is stopped. 1: frame counter 2 is running. ? fc1s: frame counter 1 status 0: frame counter 1 is stopped. 1: frame counter 1 is running. ? fc0s: frame counter 0 status 0: frame counter 0 is stopped. 1: frame counter 0 is running. ? fc0r: frame counter 0 rollover this bit is set when frame counter 0 rollover. this bit is cleared when corresponding bit scr is written to one. 31 30 29 28 27 26 25 24 ---- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------cps 76543210 csrs blks wen en fc2s fc1s fc0s fc0r
1060 42023e?sam?07/2013 atsam4l8/l4/l2 39.7.5 status clear register name: scr access type: write-only offset: 0x10 reset value: - writing a zero to a bit in this register has no effect. writing a one to a bit clears the corresponding sr bit. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------- 76543210 -------fc0r
1061 42023e?sam?07/2013 atsam4l8/l4/l2 39.7.6 data register low name: drlx access type: read/write offset: 0x14+8*x reset value: - display memory is not initialized at startup. ? data: segments value each bit defines the segment value in display memory. 31 30 29 28 27 26 25 24 data[31:24] 23 22 21 20 19 18 17 16 data[23:16] 15 14 13 12 11 10 9 8 data[15:8] 76543210 data[7:0]
1062 42023e?sam?07/2013 atsam4l8/l4/l2 39.7.7 data register high name: drhx access type: read/write offset: 0x18+8*x reset value: - ? data: segments value each bit defines the segment value in display memory. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------- 76543210 data
1063 42023e?sam?07/2013 atsam4l8/l4/l2 39.7.8 indirect access data register name: iadr access type: write-only offset: 0x34 reset value: - ? off: byte offset byte offset in display memory. ? dmask: data mask each bit is a mask for data field. when dmask[ x]=1, data[x] is not written to display memory. ? data: segments value each bit defines the segment value. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 --- off 15 14 13 12 11 10 9 8 dmask 76543210 data
1064 42023e?sam?07/2013 atsam4l8/l4/l2 39.7.9 blink confi guration register name: bcfg access type: read/write offset: 0x38 reset value: 0x00000000 ? bss1: blink segment selection 1 if bss1[x] is set, segment conn ected to seg1/comx is selected. ? bss0: blink segment selection 0 if bss0[x] is set, segment conn ected to seg0/comx is selected. ? fcs: frame counter selection ? mode: blinking mode 0: all segments are allowed to blink. 1: selected segments are allowed to blink. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 bss1 bss0 76543210 ----- fcs mode table 39-14. frame counter selection fcs frame counter 00 fc0 01 fc1 10 fc2 11 reserved
1065 42023e?sam?07/2013 atsam4l8/l4/l2 39.7.10 circular shift re gister configuration name: csrcfg access type: read/write offset: 0x3c reset value: 0x00000000 ? data: circular shift register value ? size: size defines the size of the circular shift register, (size + 1) bits. ? fcs: frame counter selection ? dir: direction 0: left shifting. 1: right shifting. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 data 76543210 - - size fcs dir table 39-15. frame counter selection fcs frame counter 00 fc0 01 fc1 10 fc2 11 reserved
1066 42023e?sam?07/2013 atsam4l8/l4/l2 39.7.11 character mapping configurati on register name: cmcfg access type: read/write offset: 0x40 reset value: 0x00000000 ? stseg: start segment defines the first segment terminal used to write the decoded display. ? tdg: type of digit ? drev: digit reverse mode 0: digit reverse mode is disabled. 1: digit reverse mode is enabled. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -- stseg 76543210 ----- tdg drev table 39-16. type of digit tdg digit 00 7-segment with 3 common terminals, com[2:0] 01 7-segment with 4 common terminals, com[3:0] 10 14-segment with 4 common terminals, com[3:0] 11 16-segment with 3 common terminals, com[2:0]
1067 42023e?sam?07/2013 atsam4l8/l4/l2 39.7.12 character mapping data register name: cmdr access type: write-only offset: 0x44 reset value: - ? ascii: ascii code 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------- 76543210 - ascii
1068 42023e?sam?07/2013 atsam4l8/l4/l2 39.7.13 automated character mapping configuration register name: acmcfg access type: read/write offset: 0x48 reset value: 0x00000000 ? dign: digit number defines the number of digit used (must be >1). ? steps: scrolling steps defines the number of steps in scrolling mode. steps = string length - dign + 1. ? stseg: start segment defines the first segment terminal used to write the decoded display. ? tdg: type of digit ? drev: digit reverse 0: digit reverse mode is disabled. 1: digit reverse mode is enabled. ?mode: mode 0: sequential. 1: scrolling. 31 30 29 28 27 26 25 24 ---- dign 23 22 21 20 19 18 17 16 steps 15 14 13 12 11 10 9 8 -- stseg 76543210 - tdg drev mode fcs en table 39-17. type of digit tdg digit 00 7-segment with 3 common terminals, com[2:0] 01 7-segment with 4 common terminals, com[3:0] 10 14-segment with 4 common terminals, com[3:0] 11 16-segment with 3 common terminals, com[2:0]
1069 42023e?sam?07/2013 atsam4l8/l4/l2 ? fcs: frame counter selection ? en: enable 0: automated character mapping is disabled. 1: automated character mapping is enabled. table 39-18. frame counter selection fcs frame counter 00 fc0 01 fc1 10 fc2 11 reserved
1070 42023e?sam?07/2013 atsam4l8/l4/l2 39.7.14 automated character mapping data register name: acmdr access type: write-only offset: 0x4c reset value: - ? ascii: ascii code 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------- 76543210 - ascii
1071 42023e?sam?07/2013 atsam4l8/l4/l2 39.7.15 automated bit mapping configuration register name: abmcfg access type: read/write offset: 0x50 reset value: 0x00000000 ? size: size defines the number of pdca writes to abmdr to form a frame (must be >1). ? fcs: frame counter selection ? en: enable 0: automated bit mapping is disabled. 1: automated bit mapping is enabled. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 --- 15 14 13 12 11 10 9 8 --- size 76543210 ----- fcs en table 39-19. frame counter selection fcs frame counter 00 fc0 01 fc1 10 fc2 11 reserved
1072 42023e?sam?07/2013 atsam4l8/l4/l2 39.7.16 automated bit mapping data register name: abmdr access type: write-only offset: 0x54 reset value: - ? off: byte offset byte offset in display memory. ? dmask: data mask each bit is a mask for data field. when dmask[ x]=1, data[x] is not written to display memory. ? data: segments value each bit defines the segment value. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 --- off 15 14 13 12 11 10 9 8 dmask 76543210 data
1073 42023e?sam?07/2013 atsam4l8/l4/l2 39.7.17 interrupt enable register name: ier access type: write-only offset: 0x58 reset value: - writing a zero to a bit in this register has no effect. writing a one to a bit in this register will set the corresponding bit in imr. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 ------- 76543210 -------fc0r
1074 42023e?sam?07/2013 atsam4l8/l4/l2 39.7.18 interrupt disable register name: idr access type: write-only offset: 0x5c reset value: - writing a zero to a bit in this register has no effect. writing a one to a bit in this register will clear the corresponding bit in imr. 31 30 29 28 27 26 25 24 ------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------- 76543210 -------fc0r
1075 42023e?sam?07/2013 atsam4l8/l4/l2 39.7.19 interrupt mask register name: imr access type: read-only offset: 0x60 reset value: 0x00000000 0: the corresponding interrupt is disabled. 1: the corresponding interrupt is enabled. a bit in this register is cleared when the corresponding bit in idr is written to one. a bit in this register is set when the corresponding bit in ier is written to one. 31 30 29 28 27 26 25 24 ---- --- 23 22 21 20 19 18 17 16 ---- --- 15 14 13 12 11 10 9 8 ---- --- 76543210 -------fc0r
1076 42023e?sam?07/2013 atsam4l8/l4/l2 39.7.20 module version name: version access type: read-only offset: 0x64 reset value: - ? variant: variant number reserved. no functionality associated. ? version: version number version number of the module. no functionality associated. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 ---- variant 15 14 13 12 11 10 9 8 ---- version[11:8] 76543210 version[7:0]
1077 42023e?sam?07/2013 atsam4l8/l4/l2 39.8 module configuration the specific configurat ion for lcdca is listed in the follo wing tables.the module bus clocks listed here are connected to the system bus clocks. refer to section 10. ?power manager (pm)? on page 108 for details. table 39-20. lcdca clocks clock name description clk_lcdca lcdca bus interface clock clk_lcd lcd 32khz clock table 39-21. register reset values register reset value version 0x00000100
1078 42023e?sam?07/2013 atsam4l8/l4/l2 table 39-22. lcdca pinout vs packages pin cluster package tqfp100 tqfp64/qfn64 tqfp48/qfn48 pa 1 2 a com0 com0 com0 pa11 com1 com1 com1 pa10 com2 com2 com2 pa09 com3 com3 com3 pc15 seg0 pc16 seg1 pc17 seg2 pc18 seg3 pc19 seg4 pa13 seg5 seg0 seg0 pa14 seg6 seg1 seg1 pa15 seg7 seg2 seg2 pa16 seg8 seg3 seg3 pa17 seg9 seg4 seg4 pc20 seg10 pc21 seg11 pc22 seg12 pc23 seg13 pb08 seg14 seg5 pb09 seg15 seg6 pb10 seg16 seg7 pb11 seg17 seg8 pa18 seg18 seg9 seg5 pa19 seg19 seg10 seg6 pa20 seg20 seg11 seg7 pb07 seg21 seg12 pb06 seg22 seg13 pa08 seg23 seg14 seg8
1079 42023e?sam?07/2013 atsam4l8/l4/l2 pc24 b seg24 pc25 seg25 pc26 seg26 pc27 seg27 pc28 seg28 pc29 seg29 pc30 seg30 pc31 seg31 pb12 c seg32 seg15 pb13 seg33 seg16 pa21 seg34 seg17 seg9 pa22 seg35 seg18 seg10 pb14 seg36 seg19 pb15 seg37 seg20 pa23 seg38 seg21 seg11 pa24 seg39 seg22 seg12 table 39-22. lcdca pinout vs packages pin cluster package tqfp100 tqfp64/qfn64 tqfp48/qfn48
1080 42023e?sam?07/2013 atsam4l8/l4/l2 40. parallel capture (parc) rev: 1.0.0.0 40.1 features ? captures 8-bits data with external input clock ? external data enables supported ? various enable conditions ? peripheral dma supported ? peripheral events supported 40.2 overview the parallel capture peripheral samples an external 8-bit bus with an external input clock. it can be connected to a cmos digital image sensor, an adc, a dsp synchronous port,... the number of parc modules implemented is dev ice specific. refer to the module configura- tion section for details. 40.3 block diagram figure 40-1. parc block diagram 40.4 i/o lines description 40.5 product dependencies in order to use this module, other parts of the system must be configured correctly, as described below. parc pcck pcdata[7:0] pcen1 pcen2 pevc events peripheral bus cpu / pdca rhr buffer i/o controller table 40-1. i/o lines description pin name pin description type pcck clock input pcd[7:0] data input pcen1 data enable 1 input pcen2 data enable 2 input
1081 42023e?sam?07/2013 atsam4l8/l4/l2 40.5.1 i/o lines the parc pins are multiplexed with other peripherals. the user must first configure the i/o con- troller to give control of the pins to the parc. 40.5.2 power management parc stops functioning when the system enters a sleep mode that disables its clock. 40.5.3 clocks the clock for parc (clk_parc) is generated by the power manager. it can be disabled either manually through the user interface of the power manager or automatically when the system enters a sleep mode that disables the clocks to the peripheral bus modules. for correct behav- ior, clk_parc frequency must be at least twice the pcck frequency. 40.5.4 dma the parc dma handshake interface is connected to the peripheral dma controller (pdca). using the parc dma functionality requires the pdca to be configured first. 40.5.5 interrupt the parc interrupt request line is connected to the nvic. using the parc interrupt requires the nvic to be configured first. 40.5.6 peripheral events the parc peripheral events are connected via the peripheral event system. refer to section 31. ?peripheral ev ent controller (pevc )? on page 844 for details. 40.6 functional description 40.6.1 capture operation parc is enabled by writing a one to the enable bit in the control register (cr.en). data cap- ture is enabled by writing a one to the start bit in the control register (cr.start) and stopped by writing a one to the stop bit in the control register (cr.stop). data capture is made by sampli ng the data bus pcd[7:0] on th e rising or falling edge of the pcck input clock then re-syn chronized to the pb clock domain. pcck sampling edge is selected with edge bit in the configuration register (cfg.edge). user can select a sampling condition to capture the data. there are four modes defined by sampling mode field (cfg.smode): when pcen1 is high, when pcen1 and pcen2 are high, when pcen1 or pcen2 is high and in last mode data is sampled without condition. data can be captured every two cycles if cfg.half bit is set to one. it can be used, for exam- ple, to capture the luminance y of a cmos digital image sensor. in addition, bit cfg.odd specifies which of odd or even bytes are captured. considering that first byte captured (byte 0), after reset, is an even byte. captured data are stored in the receive holding register (rhr). concatenated data can also be stored in rhr to make a 16-bit or a 32-bit data , with the first byte received in lsb position. concatenated data size is configured by data size bit in cfg register (cfg.dsize). when the configured data bytes are captured, the data ready bit is set to one in the status register (sr.drdy). drdy is also set to one when internal buffer is not full but cr. stop is set to one or stop event occurs (see ?peripheral events? ).
1082 42023e?sam?07/2013 atsam4l8/l4/l2 an overrun condition is detected if rhr is not read before internal buffer is full. data in rhr is corrupted and overrun bit is set to one in the status register (sr.ovr). 40.6.2 peripheral dma parc can be associated to a peripheral dma cont roller (pdca) channel. it will then perform data transfer from parc to a memory buffer without any cpu intervention (see pdca chapter for channel configuration). pdca and parc data size must be equal, if cfg.dsize is 32-bit pdca must be configured to read 32-bit data size. parc requests data transfer when internal buffer is full. when data capture is disabled (with cr.stop), parc requests a last data transfer if internal buffer contains at least one byte. 40.6.3 peripheral events data capture can be enabled or disabled by peripheral events if event mode is enabled (cfg.emode). start event enables the data capture whereas stop event disables it. 40.6.4 interrupt generation parc has two interrupt sources, data ready ( drdy) and overrun (ovr). the status of each interrupt source can be re ad from the status register. an in terrupt request will be generated if a bit in sr and the corresponding bit in the interrupt mask register (imr) are set. bits in imr are set by writing a one to the corresponding bit in the interrupt enable register (ier), and cleared by writing a one to the corresponding bit in the interrupt disable register (idr). the interrupt request remains active until the corresponding bit in sr is cleared by writing a one to the corre- sponding bit in the interrupt status clear register (icr). the interrupt sources are ored together to make one interrupt request which remains active until all interrupt bits in sr are cleared.
1083 42023e?sam?07/2013 atsam4l8/l4/l2 figure 40-2. parallel capture waveforms 0x01 0x12 0x23 0x34 0x45 0x56 0x67 0x78 0x89 0x01 0x12 0x34 0x45 0x56 0x67 0x78 0x23 0x9a 0x89 0x9a 0x01 0x12 0x34 0x45 0x56 0x67 0x78 0x23 rhr (1) rhr (2) pcen2 pcen1 pcd[7:0] pcck clk_parc (1) dsize=0, alwys=1, halfs=0, odd=0 (2) dsize=0, alwys=0, halfs=0, odd=0 (3) dsize=0, alwys=0, halfs=1, odd=0 (4) dsize=0, alwys=0, halfs=1, odd=1 (5) dsize=2, alwys=0, halfs=0, odd=0 0x01 0x45 0x67 0x23 rhr (3) 0x12 0x34 0x56 0x78 rhr (4) 0x34231201 0x78675645 rhr (5)
1084 42023e?sam?07/2013 atsam4l8/l4/l2 40.7 user interface note: 1. the reset values for these registers are device specific. refer to the module configuration section at the end of this c hapter. table 40-2. parc register memory map offset register register name access reset 0x00 configuration register cfg read/write 0x00000000 0x04 control register cr read/write 0x00000000 0x08 interrupt enable register ier write-only 0x00000000 0x0c interrupt disable register idr write-only 0x00000000 0x10 interrupt mask register imr read-only 0x00000000 0x14 status register sr read-only 0x00000000 0x18 interrupt status clear register icr write-only 0x00000000 0x1c receive holding register rhr read 0x00000000 0x20 version register version read-only - (1)
1085 42023e?sam?07/2013 atsam4l8/l4/l2 40.7.1 configuration register name: cfg access type: read/write offset: 0x00 reset value: 0x00000000 to avoid unexpected behavior cfg must be written when parc is disabled. ? odd: odd capture 0: only bytes with even index are captured. 1: only bytes with odd index are captured. ? half: half capture 0: all bytes are captured. 1: one out of two bytes are captured. ? edge: sampling edge select 0: rising edge. 1: falling edge. ? emode: events mode 0: events mode disabled. 1: events mode enabled. peripheral events start/stop data capture. ? smode: sampling mode 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 ------- - 15 14 13 12 11 10 9 8 - ------- 76543210 odd half edge emode smode dsize smode mode 0 0 capture data if pcen1 is high 0 1 capture data if pcen1 and pcen2 are high 1 0 capture data if pcen1 or pcen2 is high 1 1 always capture data
1086 42023e?sam?07/2013 atsam4l8/l4/l2 ? dsize: data size dsize size 0 0 data size in rhr is a byte (8-bit) 0 1 data size in rhr is a half-word (16-bit) 1 0 data size in rhr is a word (32-bit) 1 1 data size in rhr is a word (32-bit)
1087 42023e?sam?07/2013 atsam4l8/l4/l2 40.7.2 control register name: cr access type: read/write offset: 0x04 reset value: 0x00000000 ? stop: stop capture writing a zero to this bit has no effect. writing a one to this bit disables data capture. this bit always reads as zero. ? start: start capture writing a zero to this bit has no effect. writing a one to this bit enables data capture. this bit always reads as zero. ?dis: disable writing a zero to this bit has no effect. writing a one to this bit disables parc. this bit always reads as zero. ? en: enable writing a zero to this bit has no effect. writing a one to this bit enables parc. this bit always reads as zero. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 ------- - 15 14 13 12 11 10 9 8 - ------- 76543210 - - - - stop start dis en
1088 42023e?sam?07/2013 atsam4l8/l4/l2 40.7.3 interrupt enable register name: ier access type: write-only offset: 0x08 reset value: 0x00000000 writing a zero to a bit in this register has no effect. writing a one to a bit in this register will set the corresponding bit in imr. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------- 76543210 ----ovrdrdy--
1089 42023e?sam?07/2013 atsam4l8/l4/l2 40.7.4 interrupt disable register name: idr access type: write-only offset: 0x0c reset value: 0x00000000 writing a zero to a bit in this register has no effect. writing a one to a bit in this register will clear the corresponding bit in imr. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------- 76543210 ----ovrdrdy--
1090 42023e?sam?07/2013 atsam4l8/l4/l2 40.7.5 interrupt mask register name: imr access type: read-only offset: 0x10 reset value: 0x00000000 0: the corresponding interrupt is disabled. 1: the corresponding interrupt is enabled. a bit in this register is cleared when the corresponding bit in idr is written to one. a bit in this register is set when the corresponding bit in ier is written to one. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------- 76543210 ----ovrdrdy--
1091 42023e?sam?07/2013 atsam4l8/l4/l2 40.7.6 status register name: sr access type: read-only offset: 0x14 reset value: 0x00000000 ? ovr: overrun 0: no overrun error occurred since last read of rhr. 1: at least one overrun error occurred since last read of rhr. this bit is cleared when the corresponding bit in icr is written to one. this bit is set when a new byte has been captured and previous data in rhr has not been read. ? drdy: data ready 0: no data is ready in rhr. 1: a new data is ready. this bit is cleared when the corresponding bit in icr is written to one. this bit is set when a new data is captured (according to cr.dsize). ? cs: capture status 0: parc is not in capture mode. 1: parc is in capture mode. ? en: enable status 0: parc is disabled. 1: parc is enabled. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------- 76543210 ----ovrdrdycsen
1092 42023e?sam?07/2013 atsam4l8/l4/l2 40.7.7 interrupt status clear register name: icr access type: write-only offset: 0x18 reset value: 0x00000000 writing a zero to a bit in this register has no effect. writing a one to a bit in this register will clear the corresponding bit in sr and the corresponding interrupt request. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------- 76543210 ----ovrdrdy--
1093 42023e?sam?07/2013 atsam4l8/l4/l2 40.7.8 receive holding register name: rhr access type: read/write offset: 0x1c reset value: 0x00000000 ? cdata: captured data captured data size is defined by cr.dsize. 31 30 29 28 27 26 25 24 cdata[31:24] 23 22 21 20 19 18 17 16 cdata[23:16] 15 14 13 12 11 10 9 8 cdata[15:8] 76543210 cdata[7:0]
1094 42023e?sam?07/2013 atsam4l8/l4/l2 40.7.9 version register name: version access type: read-only offset: 0x20 reset value: - ? variant: variant number reserved. no functionality associated. ? version: version number version number of the module. no functionality associated. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 ---- variant 15 14 13 12 11 10 9 8 - - - - version[11:8] 76543210 version[7:0]
1095 42023e?sam?07/2013 atsam4l8/l4/l2 40.8 module configuration the specific configuration for each parc inst ance is listed in the following tables.the module bus clocks listed here are connected to the system bus clocks. refer to section 10. ?power man- ager (pm)? on page 108 for details. table 40-3. parc clock name module name clock name description parc clk_parc peripheral clock for parc table 40-4. register reset values register reset value version 0x00000100
1096 42023e?sam?07/2013 atsam4l8/l4/l2 41. cyclic redundancy check calculation unit (crccu) rev: 2.0.2.0 41.1 features ? performs cyclic redundancy check operation on memory area ? single ahb master interface ? apb configuration interface 41.2 overview the crccu performs crc check on memory area. 41.3 block diagram figure 41-1. crccu block diagram 41.4 product dependencies in order to use this module, other parts of the system must be configured correctly, as described below. 41.4.1 power management crccu stops functioning when the system enters a sleep mode that disables its clock. crccu resumes operation after the system wakes up from sleep mode. 41.4.2 clocks crccu clocks (c lk_crccu_apb, clk_ crccu_ahb) are generat ed by the power man- ager. they can be disabled either manually thr ough the user interface of the power manager or automatically when the system enters a sleep mode that disables the clocks to the peripheral bus modules. 41.4.3 interrupts the crccu interrupt r equest line is c onnected to the nvic. using the crccu interrupt requires the nvic to be configured first. 41.4.4 debug operation when an external debu gger forces the cpu into debug mode, crccu continues normal opera- tion. if the crccu is configured in a way that requires it to be pe riodically serviced by the cpu through interrupts or similar, improper operation or data loss may result during debugging. dma crc interface irq ahb apb clk_crccu_apb clk_crccu_ahb
1097 42023e?sam?07/2013 atsam4l8/l4/l2 41.5 functional description once configured (mode register, mr) and enabled by writing a one to mr.enable, the crc engine performs a checksum computation from memory data. crc computation is performed from lsb to msb bit. three different polynom ials (ccit802.3, castagnoli, ccit16) can be configured in mr.ptype. crccu uses its own dma mechanis m to read memory area (flash or ram area). dma uses a descriptor located in memory area. descriptor location is defined by the descriptor base address register (dscr). figure 41-2. crccu descriptor once enabled (dmaen register), dma reads descriptor to get instructions: ? addr returns the address of memory area to compute, ? ctrl.trwidth indicates the transfer size (byte, halfword or word), ? ctrl.btsize indicates the buffer size, ? ctrl.ien enables the transfer-complete interrupt. then reads data located at addr and crc engi ne computes the checksum. the crc result is available in status register (sr). btsize is automatically decremented after each read. when btsize is zero, dma is stopped and the status bit dmasr in dmasr register is set to zero. if mr.compare is set to one, crc register in descriptor is compared with the last crc com- puted. if a mismatch occurs, the error bit errisr in isr register is set to one and interrupt is generated (if not masked, see ier/idr/imr register). crccu makes single access (trwidth size) to me mory in order to limit the bandwidth usage. the field divider in mr can be used to lower the bandwidth by dividing the frequency of single accesses. the transfer request freque ncy is then divided by 2^(divider+1). addr dscr ctrl reserved reserved crc dscr+0x04 dscr+0x10 memory area data1 data2 data3 ...
1098 42023e?sam?07/2013 atsam4l8/l4/l2 to compute crc for a memory size larger than 256kbytes of for non-co ntiguous memory area, crccu can be enabled again for a new memory area. crc will be updated accordingly. con- versely, set cr.reset to one to reset the inte rmediate crc to its de fault value (0xffffffff).
1099 42023e?sam?07/2013 atsam4l8/l4/l2 41.6 user interface notes: 1. the reset value is device specific. refer to the module configuration section at the en of this chapter. table 41-1. crccu register memory map offset register register name access reset 0x00 descriptor base register dscr read/write 0x00000000 0x08 dma enable register dmaen write-only - 0x0c dma disable register dmadis write-only - 0x10 dma status register dmasr read-only 0x00000000 0x14 dma interrupt enable register dmaier write-only - 0x18 dma interrupt disable register dmaidr write-only - 0x1c dma interrupt mask register dmaimr read-only 0x00000000 0x20 dma interrupt status register dmaisr read-only 0x00000000 0x34 control register cr write-only - 0x38 mode register mr read/write 0x00000000 0x3c status register sr read-only 0xffffffff 0x40 interrupt enable register ier write-only - 0x44 interrupt disable register idr write-only - 0x48 interrupt mask register imr read-only 0x00000000 0x4c interrupt status register isr read-only 0x00000000 0xfc version register version read-only - (1) table 41-2. crccu register memory map (ram) offset register register name access reset dscr address register addr read/write - dscr + 0x04 control register ctrl read/write - dscr + 0x10 crc reference register crc read/write -
1100 42023e?sam?07/2013 atsam4l8/l4/l2 41.6.1 descriptor base address register name: dscr access type: read/write offset: 0x00 reset value: 0x00000000 ? dscr: description base address address of crc descriptor (512-byte aligned). 31 30 29 28 27 26 25 24 dscr[22:15] 23 22 21 20 19 18 17 16 dscr[14:7] 15 14 13 12 11 10 9 8 dscr[6:0] - 76543210 --------
1101 42023e?sam?07/2013 atsam4l8/l4/l2 41.6.2 dma enable register name: dmaen access type: write-only offset: 0x08 reset value: - ? dmaen: dma enable write a one to enable dma channel. writing a zero has no effect. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------- 76543210 -------dmaen
1102 42023e?sam?07/2013 atsam4l8/l4/l2 41.6.3 dma disable register name: dmadis access type: write-only offset: 0x0c reset value: - ? dmadis: dma disable write a one to disable dma channel. writing a zero has no effect. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------- 76543210 -------dmadis
1103 42023e?sam?07/2013 atsam4l8/l4/l2 41.6.4 dma status register name: dmasr access type: read-only offset: 0x10 reset value: 0x00000000 ? dmasr: dma channel status 0: dma channel is disabled. 1: dma channel is enabled. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------- 76543210 -------dmasr
1104 42023e?sam?07/2013 atsam4l8/l4/l2 41.6.5 dma interrupt enable register name: dmaier access type: write-only offset: 0x14 reset value: - ? dmaier: dma interrupt enable write a one to enable dma interrupt. writing a zero has no effect. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------- 76543210 -------dmaier
1105 42023e?sam?07/2013 atsam4l8/l4/l2 41.6.6 dma interrupt disable register name: dmaidr access type: write-only offset: 0x18 reset value: - ? dmaidr: dma interrupt disable write a one to disable dma interrupt. writing a zero has no effect. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------- 76543210 -------dmaidr
1106 42023e?sam?07/2013 atsam4l8/l4/l2 41.6.7 dma interrupt mask register name: dmaimr access type: read-only offset: 0x1c reset value: 0x00000000 ? dmaimr: dma interrupt mask status 0: dma interrupt is disabled. 1: dma interrupt is enabled. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------- 76543210 -------dmaimr
1107 42023e?sam?07/2013 atsam4l8/l4/l2 41.6.8 dma interrupt status register name: dmaisr access type: read-only offset: 0x20 reset value: 0x00000000 ? dmaisr: dma interrupt status 0: no dma transfer or in-progress. 1: dma transfer is completed. this bit is set to zero when dmaisr is read. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------- 76543210 -------dmaisr
1108 42023e?sam?07/2013 atsam4l8/l4/l2 41.6.9 control register name: cr access type: write-only offset: 0x34 reset value: - ? reset: reset crccomputation write a one to reset sr. writing a zero has no effect. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------- 76543210 - - - - - - - reset
1109 42023e?sam?07/2013 atsam4l8/l4/l2 41.6.10 mode register name: mr access type: read/write offset: 0x38 reset value: 0x00000000 ? divider: bandwidth divider dma bandwidth, required for crc computation, is divided by 2^(divider+1). ? ptype: polynomial type ? compare: crc compare 0: no comparison. 1: crc computed is compared with stored value. ? enable: crc computation enable 0: no computation. 1: crc computation enabled. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------- 76543210 divider ptype compare enable value name description 0 ccit8023 polynom 0x04c11db7 1 castagnoli polynom 0x1edc6f41 2 ccit16 polynom 0x1021
1110 42023e?sam?07/2013 atsam4l8/l4/l2 41.6.11 status register name: sr access type: read-only offset: 0x3c reset value: 0xffffffff ? crc: cyclic redundancy check value crc computation result. if mr.compare=1, sr is not readable. 31 30 29 28 27 26 25 24 crc[31:24] 23 22 21 20 19 18 17 16 crc[23:16] 15 14 13 12 11 10 9 8 crc[15:8] 76543210 crc[7:0]
1111 42023e?sam?07/2013 atsam4l8/l4/l2 41.6.12 interrupt enable register name: ier access type: write-only offset: 0x40 reset value: ? writing a zero to a bit in this register has no effect. writing a one to a bit in this register will set the corresponding bit in imr 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------- 76543210 -------errier
1112 42023e?sam?07/2013 atsam4l8/l4/l2 41.6.13 interrupt disable register name: idr access type: write-only offset: 0x44 reset value: ? writing a zero to a bit in this register has no effect. writing a one to a bit in this register will clear the corresponding bit in imr 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------- 76543210 -------erridr
1113 42023e?sam?07/2013 atsam4l8/l4/l2 41.6.14 interrupt mask register name: imr access type: read-only offset: 0x48 reset value: 0x00000000 0: the corresponding interrupt is disabled. 1: the corresponding interrupt is enabled. this bit is cleared when the corresponding bit in idr is written to one. this bit is set when the corresponding bit in ier is written to one. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------- 76543210 -------errimr
1114 42023e?sam?07/2013 atsam4l8/l4/l2 41.6.15 interrupt status register name: isr access type: read-only offset: 0x4c reset value: 0x00000000 ? errisr: crc error interrupt status 0: no crc error 1: crc error, crc computed and crc stored are different. errisr is cleared when this register is read. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------- 76543210 -------errisr
1115 42023e?sam?07/2013 atsam4l8/l4/l2 41.6.16 version register name: version access type: read-only offset: 0xfc reset value: - ? variant: variant number reserved. no functionality associated. ? version: version number version number of the module. no functionality associated. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 ----- variant 15 14 13 12 11 10 9 8 - - - - version[11:8] 76543210 version[7:0]
1116 42023e?sam?07/2013 atsam4l8/l4/l2 41.6.17 transfer address register name: addr access type: read/write offset: dscr reset value: - ? addr: transfer address address of memory block to compute. 31 30 29 28 27 26 25 24 addr[31:24] 23 22 21 20 19 18 17 16 addr[23:16] 15 14 13 12 11 10 9 8 addr[15:8] 76543210 addr[7:0]
1117 42023e?sam?07/2013 atsam4l8/l4/l2 41.6.18 transfer control register name: ctrl access type: read/write offset: dscr + 0x04 reset value: - ? ien: interrupt mask enable 0: interrupt is enabled 1: interrupt is masked ? trwidth: transfer width ? btsize: buffer transfer size buffer transfert size 31 30 29 28 27 26 25 24 ----ien- trwidth 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 btsize[15:8] 0 btsize[7:0] trwidth size 00 byte 01 halfword 10 word
1118 42023e?sam?07/2013 atsam4l8/l4/l2 41.6.19 transfer reference register name: crc access type: read/write offset: dscr + 0x10 reset value: - ? refcrc: reference crc when compare mode is enabled, checksum is compared with this register. 31 30 29 28 27 26 25 24 refcrc[31:24] 23 22 21 20 19 18 17 16 refcrc[23:16] 15 14 13 12 11 10 9 8 refcrc[15:8] 76543210 refcrc[7:0]
1119 42023e?sam?07/2013 atsam4l8/l4/l2 41.7 module configuration the specific configuration for each crccu instance is listed in the following tables.the module bus clocks listed here are connected to the system bus clocks. refer to section 10. ?power man- ager (pm)? on page 108 for details. table 41-3. crccu clock name clock name description clk_crccu_apb clock for the crccu bus interface clk_crccu_ahb clock for the crccu ahb interface register reset value version 0x00000202
1120 42023e?sam?07/2013 atsam4l8/l4/l2 42. electrical characteristics 42.1 absolute maximum ratings* 42.2 operating conditions all the electrical characteristics are applicable to the following conditions unless otherwise spec- ified : ? operating voltage range 1,68v to 3,6v for vddin, vddio & vddana ? power scaling 0 and 2 modes ? operating temperature range: ta = -40c to 85c and for a junction temperature up to tj = 100c. typical values are base on ta = 25c and v ddin,vddio,vddana = 3,3v unless otherwise specified 42.3 supply characteristics refer to section 5. ?power and startup considerations? on page 42 for details about power supply table 42-1. absolute maximum ratings operating temperature..................................... -40 c to +85 c *notice: stresses beyond those listed under ?absolute maxi- mum ratings? may cause permanent damage to the device. this is a stress rating only and functional operation of the device at these or other conditions beyond those indicated in the operational sections of this specification is not implied. exposure to absolute maximum rating conditions for extended periods may affect device reliability. storage temperature...................................... -60c to +150c voltage on input pins with respect to ground ..........................-0.3v to v vdd (1) +0.3v 1. v vdd corresponds to either v vddin or v vddio , depending on the supply for the pin. refer to section 3-5 on page 12 for details total dc output current on all i/o pins vddio ......................................................................... 120 ma total dc output current on all i/o pins vddin ........................................................................ 100 ma total dc output current on all i/o pins vddana........................................................................ 50 ma maximum operating voltage vddio, vddin .................... 3.6v table 42-2. supply characteristics symbol conditions voltag e min max unit v vddio, v vddin, v vddana ps1 (fcpu<=12mhz) linear mode 1.68 3.6 v ps0 & ps2 (fcpu>12mhz) linear mode 1.8 switching mode 2.0 (1) 1. below 2.3v, linear mode is more power efficient than switching mode.
1121 42023e?sam?07/2013 atsam4l8/l4/l2 table 42-3. supply rise rates and order (1) vddio, vddin and vddana must be connected together and as a consequence, rise synchronously 1. these values are based on characterization. th ese values are not covered by test limits in production. symbol parameter rise rate min max unit comment v vddio dc supply peripheral i/os 0.0001 2.5 v/s v vddin dc supply peripheral i/os and internal regulator 0.0001 2.5 v/s v vddana analog supply voltage 0.0001 2.5 v/s
1122 42023e?sam?07/2013 atsam4l8/l4/l2 42.4 maximum clock frequencies table 42-4. maximum clock frequencies in po wer scaling mode 0/2 and run mode symbol parameter description max units f cpu cpu clock frequency 48 mhz f pba pba clock frequency 48 f pbb pbb clock frequency 48 f pbc pbc clock frequency 48 f pbd pbd clock frequency 48 f gclk0 gclk0 clock frequency dfllif main reference, gclk0 pin 50 f gclk1 gclk1 clock frequency dfllif dithering and ssg reference, gclk1 pin 50 f gclk2 gclk2 clock frequency ast, gclk2 pin 20 f gclk3 gclk3 clock frequency catb, gclk3 pin 50 f gclk4 gclk4 clock frequency flo and aesa 50 f gclk5 gclk5 clock frequency gloc, tc0 and rc32kifb_ref 80 f gclk6 gclk6 clock frequency abdacb and iisc 50 f gclk7 gclk7 clock frequency usbc 50 f gclk8 gclk8 clock frequency tc1 and pevc[0] 50 f gclk9 gclk9 clock frequency pll0 and pevc[1] 50 f gclk10 gclk10 clock frequency adcife 50 f gclk11 gclk11 clock frequency master generic clock. can be used as source for other generic clocks 150 f osc0 osc0 output frequency oscillator 0 in crystal mode 30 oscillator 0 in digital clock mode 50 f pll pll output frequency phase locked loop 240 f dfll dfll output frequency digital frequency locked loop 220 f rc80m rc80m output frequency internal 80mhz rc oscillator 80
1123 42023e?sam?07/2013 atsam4l8/l4/l2 table 42-5. maximum clock frequencies in po wer scaling mode 1 and run mode symbol parameter description max units f cpu cpu clock frequency 12 mhz f pba pba clock frequency 12 f pbb pbb clock frequency 12 f pbc pbc clock frequency 12 f pbd pbd clock frequency 12 f gclk0 gclk0 clock frequency dfllif main reference, gclk0 pin 16.6 f gclk1 gclk1 clock frequency dfllif dithering and ssgreference, gclk1 pin 16.6 f gclk2 gclk2 clock frequency ast, gclk2 pin 6.6 f gclk3 gclk3 clock frequency catb, gclk3 pin 17.3 f gclk4 gclk4 clock frequency flo and aesa 16.6 f gclk5 gclk5 clock frequency gloc, tc0 and rc32kifb_ref 26.6 f gclk6 gclk6 clock frequency abdacb and iisc 16.6 f gclk7 gclk7 clock frequency usbc 16.6 f gclk8 gclk8 clock frequency tc1 and pevc[0] 16.6 f gclk9 gclk9 clock frequency pll0 and pevc[1] 16.6 f gclk10 gclk10 clock frequency adcife 16.6 f gclk11 gclk11 clock frequency master generic clock. can be used as source for other generic clocks 51.2 f osc0 osc0 output frequency oscillator 0 in crystal mode 16 oscillator 0 in digital clock mode 16 f pll pll output frequency phase locked loop n/a f dfll dfll output frequency digital frequency locked loop n/a f rc80m rc80m output frequency internal 80mhz rc oscillator n/a
1124 42023e?sam?07/2013 atsam4l8/l4/l2 42.5 power consumption 42.5.1 power scaling 0 and 2 the values in table 42-6 are measured values of power consumption under the following condi- tions, except where noted: ? operating conditions for power scaling mode 0 and 2 ?v vddin = 3.3v ? power scaling mode 0 is used for cpu frequencies under 36mhz ? power scaling mode 2 is used for cpu frequencies above 36mhz ? wake up time from low power modes is measured from the edge of the wakeup signal to the first instruction fetched in flash. ? oscillators ? osc0 (crystal o scillator) stopped ? osc32k (32khz crystal oscillator) running with external 32khz crystal ? dfll using osc32k as reference and running at 48mhz ? clocks ? dfll used as main clock source ? cpu, ahb clocks undivided ? apbc and apbd clocks divided by 4 ? apba and apbb bridges off ? the following peripheral clocks running ? pm, scif, ast, flashcalw, apbc and apbd bridges ? all other peripheral clocks stopped ? i/os are inactive with internal pull-up ? cpu is running on flash with 1 wait state ? low power cache enabled ? bod18 and bod33 disabled table 42-6. atsam4l4/2 current consumption and wakeup time for power scaling mode 0 and 2 mode conditions t a typical wakeup time typ max (1) unit run cpu running a fibonacci algorithm linear mode 25c n/a 296 326 a/mhz 85c 300 332 cpu running a coremark algorithm linear mode 25c n/a 320 377 85c 326 380 cpu running a fibonacci algorithm switching mode 25c n/a 177 198 85c 179 200 cpu running a coremark algorithm switching mode 25c n/a 186 232 85c 195 239
1125 42023e?sam?07/2013 atsam4l8/l4/l2 sleep0 switching mode 25c 9 * main clock cycles 3817 4033 a 85c 3934 4174 sleep1 switching mode 25c 9 * main clock cycles + 500ns 2341 2477 85c 2437 2585 sleep2 switching mode 25c 9 * main clock cycles + 500ns 1758 1862 85c 1847 1971 sleep3 linear mode 25c 51 60 wait osc32k and ast running fast wake-up enable 1.5s 5.9 8.7 osc32k and ast stopped fast wake-up enable 4.7 7.6 retention osc32k running ast running at 1khz 1.5s 3.1 5.1 ast and osc32k stopped 2.2 4.2 backup osc32k running ast running at 1khz 1.5 3.1 ast and osc32k stopped 0.9 1.7 1. these values are based on characterization. these values are not covered by test limits in production. table 42-6. atsam4l4/2 current consumption and wakeup time for power scaling mode 0 and 2 mode conditions t a typical wakeup time typ max (1) unit table 42-7. atsam4l8 current consumption and wakeup time for power scaling mode 0 and 2 mode conditions t a typical wakeup time typ max (1) unit run cpu running a fibonacci algorithm linear mode 25c n/a 319 343 a/mhz 85c 326 350 cpu running a coremark algorithm linear mode 25c n/a 343 387 85c 351 416 cpu running a fibonacci algorithm switching mode 25c n/a 181 198 85c 186 203 cpu running a coremark algorithm switching mode 25c n/a 192 232 85c 202 239
1126 42023e?sam?07/2013 atsam4l8/l4/l2 42.5.2 power scaling 1 the values in table 34-7 are measured values of power consumption under the following condi- tions, except where noted: ? operating conditions for power scaling mode 1 ?v vddin = 3.3v ? wake up time from low power modes is measured from the edge of the wakeup signal to the first instruction fetched in flash. ? oscillators ? osc0 (crystal oscillator) and osc32k (32khz crystal o scillator) stopped ? rcfast running at 12mhz ? clocks ? rcfast used as main clock source ? cpu, ahb clocks undivided ? apbc and apbd clocks divided by 4 ? apba and apbb bridges off ? the following peripheral clocks running ? pm, scif, ast, flashcalw, apbc and apbd bridges sleep0 switching mode 25c 9 * main clock cycles 3817 4033 a 85c 4050 4507 sleep1 switching mode 25c 9 * main clock cycles + 500ns 2341 2477 85c 2525 2832 sleep2 switching mode 25c 9 * main clock cycles + 500ns 1758 1862 85c 1925 1971 sleep3 linear mode 25c 51 60 wait osc32k and ast running fast wake-up enable 1.5s 6.7 osc32k and ast stopped fast wake-up enable 5.5 retention osc32k running ast running at 1khz 1.5s 3.9 ast and osc32k stopped 3.0 backup osc32k running ast running at 1khz 1.5 3.1 ast and osc32k stopped 0.9 1.7 1. these values are based on characterization. these values are not covered by test limits in production. table 42-7. atsam4l8 current consumption and wakeup time for power scaling mode 0 and 2 mode conditions t a typical wakeup time typ max (1) unit
1127 42023e?sam?07/2013 atsam4l8/l4/l2 ? all other peripheral clocks stopped ? i/os are inactive with internal pull-up ? cpu is running on flash with 1 wait state ? low power cache enabled ? bod18 and bod33 disabled table 42-8. atsam4l4/2 current consumption and wakeup time for power scaling mode 1 mode conditions t a typical wakeup time typ max (1) unit run cpu running a fibonacci algorithm linear mode 25c n/a 205 224 a/mhz 85c 212 231 cpu running a coremark algorithm linear mode 25c n/a 213 244 85c 230 270 cpu running a fibonacci algorithm switching mode 25c n/a 95 112 85c 100 119 cpu running a coremark algorithm switching mode 25c n/a 100 128 85c 107 138 sleep0 switching mode 25c 9 * main clock cycles 527 627 a 85c 579 739 sleep1 switching mode 25c 9 * main clock cycles + 500ns 369 445 85c 404 564 sleep2 switching mode 25c 9 * main clock cycles + 500ns 305 381 85c 334 442 sleep3 linear mode 25c 46 55 wait osc32k and ast running fast wake-up enable 1.5s 4.7 7.5 osc32k and ast stopped fast wake-up enable 3.5 6.3 retention osc32k running ast running at 1khz 1.5s 2.6 4.8 ast and osc32k stopped 1.5 4 backup osc32k running ast running at 1khz 1.5 3.1 ast and osc32k stopped 0.9 1.7 1. these values are based on characterization. these values are not covered by test limits in production.
1128 42023e?sam?07/2013 atsam4l8/l4/l2 table 42-9. atsam4l8 current consumption and wakeup time for power scaling mode 1 mode conditions t a typical wakeup time typ max (1) unit run cpu running a fibonacci algorithm linear mode 25c n/a 222 240 a/mhz 85c 233 276 cpu running a coremark algorithm linear mode 25c n/a 233 276 85c 230 270 cpu running a fibonacci algorithm switching mode 25c n/a 100 112 85c 100 119 cpu running a coremark algorithm switching mode 25c n/a 104 128 85c 107 138 sleep0 switching mode 25c 9 * main clock cycles 527 627 a 85c 579 739 sleep1 switching mode 25c 9 * main clock cycles + 500ns 369 445 85c 404 564 sleep2 switching mode 25c 9 * main clock cycles + 500ns 305 381 85c 334 442 sleep3 linear mode 25c 46 55 wait osc32k and ast running fast wake-up enable 1.5s 5.5 osc32k and ast stopped fast wake-up enable 4.3 retention osc32k running ast running at 1khz 1.5s 3.4 ast and osc32k stopped 2.3 backup osc32k running ast running at 1khz 1.5 3.1 ast and osc32k stopped 0.9 1.7 1. these values are based on characterization. these values are not covered by test limits in production. table 42-10. typical power consumption running coremark on cpu clock sources (1) clock source conditions regulator frequency (mhz) typ unit
1129 42023e?sam?07/2013 atsam4l8/l4/l2 rcsys (mcsel = 0) power scaling mode 1 switching mode 0.115 978 a/mhz osc0 (mcsel = 1) power scaling mode 1 0.5 354 12 114 power scaling mode 0 12 228 30 219 osc0 (mcsel = 1) external clock (mode=0) power scaling mode 1 0.6 292 12 111 power scaling mode 0 12 193 power scaling mode 2 50 194 pll (mcsel = 2) power scaling mode 2 input freq = 4mhz from osc0 40 188 50 185 dfll (mcsel = 3) power scaling mode 0 input freq = 32khz from osc32k 20 214 power scaling mode 2 input freq = 32khz from osc32k 50 195 rc1m (mcsel = 4) power scaling mode 1 1 267 rcfast (mcsel = 5) power scaling mode 1 rcfast frequency is configurable from 4 to 12mhz 4153 12 114 rc80m (mcsel = 6) power scaling mode 2 f cpu = rc80m / 2 = 40mhz 40 211 1. these values are based on characterization. these values are not covered by test limits in production. table 42-10. typical power consumption running coremark on cpu clock sources (1)
1130 42023e?sam?07/2013 atsam4l8/l4/l2 figure 42-1. typical power consumption runni ng coremark (from above table) note: for variable frequency oscillators, linear interpolation between high and low settings figure 42-2. measurement schematic, switching mode vddin vddout vddcore vddio vddana amp 0
1131 42023e?sam?07/2013 atsam4l8/l4/l2 42.5.3 peripheral power consumption in power scaling mode 0 and 2 the values in table 42-11 are measured values of power consumption under the following conditions: ? operating conditions, internal core supply ( figure 42-2 ) ?v vddin = 3.3v ?v vddcore supplied by the internal r egulator in switching mode ?t a = 25 c ? oscillators ? osc0 (crystal oscillator) stopped ? osc32k (32khz crystal oscillator) running with external 32khz crystal ? dfll running at 48mhz with osc32k as reference clock ? clocks ? dfll used as main clock source ? cpu, ahb, and pb clocks undivided ? i/os are inactive with internal pull-up ? flash enabled in high speed mode ? cpu in sleep0 mode ? bod18 and bod33 disabled consumption active is the added current consumption when the module clock is turned on.
1132 42023e?sam?07/2013 atsam4l8/l4/l2 42.5.4 . peripheral power consumption in power scaling mode 1 the values in table 42-13 are measured values of power consumption under the following conditions: table 42-11. typical current consumption by peripheral in power scaling mode 0 and 2 (1) 1. these numbers are valid for the measured condit ion only and must not be extrapolated to other frequencies peripheral typ consumption active unit iisc 1.0 a/mhz spi 1.9 tc 6.3 twim 1.5 twis 1.2 usart 8.5 adcife (2) 3.1 dacc 1.3 acifc (2) 2. includes the current consumption on vddana and advrefp. 3.1 gloc 0.4 abdacb 0.7 trng 0.9 pa r c 0 . 7 catb 3.0 lcdca 4.4 pdca 1.0 crccu 0.3 usbc 1.5 pevc 5.6 chipid 0.1 scif 6.4 freqm 0.5 gpio 7.1 bpm 0.9 bscif 4.6 ast 1.5 wdt 1.4 eic 0.6 picouart 0.3
1133 42023e?sam?07/2013 atsam4l8/l4/l2 ? operating conditions, internal core supply ( figure 42-2 ) ?v vddin = 3.3v ?v vddcore = 1.2 v, supplied by the internal regulator in switching mode ?t a = 25 c ? oscillators ? osc0 (crystal oscillator) stopped ? osc32k (32khz crystal oscillator) running with external 32khz crystal ? rcfast running @ 12mhz ? clocks ? rcfast used as main clock source ? cpu, ahb, and pb clocks undivided ? i/os are inactive with internal pull-up ? flash enabled in normal mode ? cpu in sleep0 mode ? bod18 and bod33 disabled consumption active is the added current consumption when the module clock is turned on
1134 42023e?sam?07/2013 atsam4l8/l4/l2 table 42-12. typical current consumption by peripheral in power scaling mode 1 (1) 1. these numbers are valid for the measured condit ion only and must not be extrapolated to other frequencies peripheral typ consumption active unit iisc 0.5 a/mhz spi 1.1 tc 3.1 twim 0.8 twis 0.7 usart 4.4 adcife (2) 1.6 dacc 0.6 acifc (2) 2. includes the current consumption on vddana and advrefp. 1.6 gloc 0.1 abdacb 0.3 trng 0.3 pa r c 0 . 3 catb 1.5 lcdca 2.2 pdca 0.4 crccu 0.3 usbc 0.9 pevc 2.8 chipid 0.1 scif 3.1 freqm 0.2 gpio 3.4 bpm 0.4 bscif 2.3 ast 0.8 wdt 0.8 eic 0.3 picouart 0.2
1135 42023e?sam?07/2013 atsam4l8/l4/l2 42.6 i/o pin c haracteristics 42.6.1 normal i/o pin table 42-13. normal i/o pin characteristics (1) 1. v vdd corresponds to either v vddin or v vddio , depending on the supply for the pin. refer to section 3-5 on page 12 for details symbol parameter conditions min typ max units r pullup pull-up resistance (2) 2. these values are based on simulation. these values are no t covered by test limits in production or characterization 40 k r pulldown pull-down resistance (2) 40 k v il input low-level voltage -0.3 0.2 * v vdd v v ih input high-level voltage 0.8 * v vdd v vdd + 0.3 v ol output low-level voltage 0.4 v oh output high-level voltage v vdd - 0.4 i ol output low-level current (3) odcr0=0 1.68v2.7v load = 25pf 17 mhz osrr0=1 15 mhz osrr0=0 odcr0=1, v vdd >2.7v load = 25pf 27 mhz osrr0=1 23 mhz i leak input leakage current (3) pull-up resistors disabled 0.01 1 a c in input capacitance (2) 5pf
1136 42023e?sam?07/2013 atsam4l8/l4/l2 3. these values are based on characterization. these values are not covered by test limits in production 42.6.2 high-drive i/o pin : pa02, pc04, pc05, pc06 table 42-14. high-drive i/o pin characteristics (1) symbol parameter conditions min typ max units r pullup pull-up resistance (2) 40 k r pulldown pull-down resistance (2) 40 k v il input low-level voltage -0.3 0.2 * v vdd v v ih input high-level voltage 0.8 * v vdd v vdd + 0.3 v ol output low-level voltage 0.4 v oh output high-level voltage v vdd - 0.4 i ol output low-level current (3) odcr0=0 1.68v2.7v load = 25pf 22 mhz osrr0=1 17 mhz osrr0=0 odcr0=1, v vdd >2.7v load = 25pf 35 mhz osrr0=1 26 mhz i leak input leakage current (3) pull-up resistors disabled 0.01 2 a c in input capacitance (2) 10 pf 1. v vdd corresponds to either v vddin or v vddio , depending on the supply for the pin. refer to section 3-5 on page 12 for details 2. these values are based on simulation. these values are no t covered by test limits in production or characterization 3. these values are based on characterization. these values are not covered by test limits in production
1137 42023e?sam?07/2013 atsam4l8/l4/l2 42.6.3 usb i/o pin : pa25, pa26 42.6.4 twi pin : pa21, pa22, pa23, pa24, pb14, pb15 table 42-15. usb i/o pin characteristics in gpio configuration (1) 1. v vdd corresponds to either v vddin or v vddio , depending on the supply for the pin. refer to section 3-5 on page 12 for details symbol parameter conditions min typ max units r pullup pull-up resistance (2) 2. these values are based on simulation. these values are no t covered by test limits in production or characterization 40 k r pulldown pull-down resistance (2) 40 k v il input low-level voltage -0.3 0.2 * v vdd v v ih input high-level voltage 0.8 * v vdd v vdd + 0.3 v ol output low-level voltage 0.4 v oh output high-level voltage v vdd - 0.4 i ol output low-level current (3) 3. these values are based on characterization. these values are not covered by test limits in production odcr0=0 1.68v 1138 42023e?sam?07/2013 atsam4l8/l4/l2 i cs current source (3) driveh=0 0.5 ma driveh=1 1 driveh=2 1.5 driveh=3 3 f max max frequency (2) hsmode with current source; drivex=3, slew=0 cbus = 400pf, v vdd = 1.68v 3.5 6.4 mhz t rise rise time (2) hsmode mode, drivex=3, slew=0 cbus = 400pf, rp = 440ohm, v vdd = 1.68v 28 38 ns t fall fall time (2) standard mode, drivex=3, slew=0 cbus = 400pf, rp = 440ohm, v vdd = 1.68v 50 95 ns hsmode mode, drivex=3, slew=0 cbus = 400pf, rp = 440ohm, v vdd = 1.68v 50 95 1. v vdd corresponds to either v vddin or v vddio , depending on the supply for the pin. refer to section 3-5 on page 12 for details 2. these values are based on simulation. these values are no t covered by test limits in production or characterization 3. these values are based on characterization. these values are not covered by test limits in production table 42-16. twi pin characteristics in twi configuration (1) symbol parameter conditions min typ max units table 42-17. twi pin characteristics in gpio configuration (1) symbol parameter conditions min typ max units r pullup pull-up resistance (2) 40 k r pulldown pull-up resistance (2) 40 k v il input low-level voltage -0.3 0.2 * v vdd v v ih input high-level voltage 0.8 * v vdd v vdd + 0.3 v v ol output low-level voltage 0.4 v v oh output high-level voltage v vdd - 0.4 i ol output low-level current (3) odcr0=0 1.68v 1139 42023e?sam?07/2013 atsam4l8/l4/l2 t rise rise time (2) osrr0=0 odcr0=0 1.68v 1140 42023e?sam?07/2013 atsam4l8/l4/l2 42.6.5 high drive twi pin : pb00, pb01 table 42-19. high drive twi pin characteristics in twi configuration (1) 1. v vdd corresponds to either v vddin or v vddio , depending on the supply for the pin. refer to section 3-5 on page 12 for details symbol parameter conditions min typ max units r pullup pull-up resistance (2) 2. these values are based on simulation. these values are no t covered by test limits in production or characterization pb00, pb01 40 k r pulldown pull-down resistance (2) 40 k v il input low-level voltage -0.3 0.3 * v vdd v v ih input high-level voltage 0.7 * v vdd v vdd + 0.3 v ol output low-level voltage 0.4 v oh output high-level voltage v vdd - 0.4 i ol output low-level current (3) 3. these values are based on characterization. these values are not covered by test limits in production drivel=0 0.5 ma drivel=1 1.0 drivel=2 1.6 drivel=3 3.1 drivel=4 6.2 drivel=5 9.3 drivel=6 15.5 drivel=7 21.8 i cs current source (2) driveh=0 0.5 ma driveh=1 1 driveh=2 1.5 driveh=3 3 f max max frequency (2) hsmode with current source; drivex=3, slew=0 cbus = 400pf, v vdd = 1.68v 3.5 6.4 mhz t rise rise time (2) hsmode mode, drivex=3, slew=0 cbus = 400pf, rp = 440ohm, v vdd = 1.68v 28 38 ns t fall fall time (2) standard mode, drivex=3, slew=0 cbus = 400pf, rp = 440ohm, v vdd = 1.68v 50 95 ns hsmode mode, drivex=3, slew=0 cbus = 400pf, rp = 440ohm, v vdd = 1.68v 50 95
1141 42023e?sam?07/2013 atsam4l8/l4/l2 table 42-20. high drive twi pin characterist ics in gpio configuration (1) symbol parameter conditions min typ max units r pullup pull-up resistance (2) 40 k r pulldown pull-up resistance (2) 40 k v il input low-level voltage -0.3 0.2 * v vdd v v ih input high-level voltage 0.8 * v vdd v vdd + 0.3 v ol output low-level voltage 0.4 v oh output high-level voltage v vdd - 0.4 i ol output low-level current (3) odcr0=0 1.68v 1142 42023e?sam?07/2013 atsam4l8/l4/l2 42.7 oscillator characteristics 42.7.1 oscillator 0 (osc0) characteristics 42.7.1.1 digital clock characteristics the following table describes the characteristics for the oscillator when a digital clock is applied on xin. 42.7.1.2 crystal oscillator characteristics the following table describes the characteristics for the oscillator when a crystal is connected between xin and xout as shown in figure 42-3 . the user must choose a crystal oscillator where the crystal load capacitance c l is within the range given in the table. the exact value of c l can be found in the crystal datasheet. the capacitance of the external capacitors (c lext ) can then be computed as follows: where c stray is the capacitance of the pins and pcb, c shunt is the shunt capacitance of the crystal. table 42-22. digital clock ch aracteristics symbol parameter conditions min typ max units f cpxin xin clock frequency (1) 50 mhz t cpxin xin clock duty cycle (1) 40 60 % t startup startup time n/a cycles 1. these values are based on simulation. these values are no t covered by test limits in production or characterization. c lext 2c l c stray c shunt ? ? () = table 42-23. crystal oscillator characteristics symbol parameter conditions min typ max unit f out crystal oscillator frequency (1) 0.6 30 mhz esr crystal equivalent series resistance (2) f = 0.455mhz, c lext = 100pf scif.oscctrl.gain = 0 17000 f = 2mhz, c lext = 20pf scif.oscctrl.gain = 0 2000 f = 4mhz, c lext = 20pf scif.oscctrl.gain = 1 1500 f = 8mhz, c lext = 20pf scif.oscctrl.gain = 2 300 f = 16mhz, c lext = 20pf scif.oscctrl.gain = 3 350 f = 30mhz, c lext = 18pf scif.oscctrl.gain = 4 45
1143 42023e?sam?07/2013 atsam4l8/l4/l2 figure 42-3. oscillator connection c l crystal load capacitance (1) 618 pf c shunt crystal shunt capacitance (1) 7 c xin parasitic capacitor load (2) tqfp100 package 4.91 c xout parasitic capacitor load (2) 3.22 t startup startup time (1) scif.oscctrl.gain = 2 30 000 (3) cycles i osc current consumption (1) active mode, f = 0.6mhz, scif.oscctrl.gain = 0 30 a active mode, f = 4mhz, scif.oscctrl.gain = 1 130 active mode, f = 8mhz, scif.oscctrl.gain = 2 260 active mode, f = 16mhz, scif.oscctrl.gain = 3 590 active mode, f = 30mhz, scif.oscctrl.gain = 4 960 1. these values are based on simulation. these values are no t covered by test limits in production or characterization. 2. these values are based on characterization. these values are not covered by test limits in production. 3. nominal crystal cycles. table 42-23. crystal oscillator characteristics symbol parameter conditions min typ max unit c shunt l m r m c m c stray c lext c lext xin xout crystal
1144 42023e?sam?07/2013 atsam4l8/l4/l2 42.7.2 32khz crystal oscillator (osc32k) characteristics figure 42-3 and the equation above also applies to th e 32khz oscillator connection. the user must choose a crystal oscillator wh ere the crystal load capacitance c l is within the range given in the table. the exact value of c l can then be found in the crystal datasheet. table 42-24. digital clock ch aracteristics symbol parameter conditions min typ max units f cpxin32 xin32 clock frequency (1) 6mhz xin32 clock duty cycle (1) 40 60 % t startup startup time n/a cycles 1. these values are based on simulation. these values are no t covered by test limits in production or characterization. table 42-25. 32 khz crystal oscilla tor characteristics symbol parameter conditions min typ max unit f out crystal oscillator frequency 32 768 hz t startup startup time (1) r m = 100k , c l = 12.5pf 30000 (2) cycles c l crystal load capacitance (1) 612.5 pf c shunt crystal shunt capacitance (1) 0.8 1.7 c xin parasitic capacitor load (3) tqfp100 package 3.4 c xout parasitic capacitor load (3) 2.72 i osc32k current consumption (1) 350 na esr xtal crystal equivalent series resistance (1) f=32.768khz oscctrl32.mode=1 safety factor = 3 oscctrl32.selcurr=0 c l =6pf 28 k oscctrl32.selcurr=4 72 oscctrl32.selcurr=8 114 oscctrl32.selcurr=15 313 oscctrl32.selcurr=0 c l =9pf 14 k oscctrl32.selcurr=4 36 oscctrl32.selcurr=8 100 oscctrl32.selcurr=15 170 crystal equivalent series resistance (3) f=32.768khz oscctrl32.mode=1 safety factor = 3 oscctrl32.selcurr=4 c l =12.5pf 15.2 k oscctrl32.selcurr=6 61.8 oscctrl32.selcurr=8 101.8 oscctrl32.selcurr=10 138.5 oscctrl32.selcurr=15 228.5 1. these values are based on simulation. these values are no t covered by test limits in production or characterization. 2. nominal crystal cycles. 3. these values are based on characterization. these values are not covered by test limits in production.
1145 42023e?sam?07/2013 atsam4l8/l4/l2 42.7.3 phase locked loop (pll) characteristics 42.7.4 digital frequency locked loop (dfll) characteristics table 42-26. phase locked loop characteristics symbol parameter conditions min typ max unit f out output frequency (1) 1. these values are based on simulation. these values are no t covered by test limits in production or characterization. pll is not availabe in ps1 48 240 mhz f in input frequency (1) 416 i pll current consumption (1) fout=80mhz 200 a fout=240mhz 500 t startup startup time, from enabling the pll until the pll is locked (1) wide bandwidth mode disabled 8 s wide bandwidth mode enabled 30 table 42-27. digital frequency locked loop characteristics symbol parameter conditions min typ max unit f out output frequency (1) dfll is not availabe in ps1 20 150 mhz f ref reference frequency (1) 8 150 khz accuracy (1) fine lock, f ref = 32khz, ssg disabled (2) 0.1 0.5 % accurate lock, f ref = 32khz, dither clk rcsys/2, ssg disabled (2) 0.06 0.5 fine lock, f ref = 8-150khz, ssg disabled (2) 0.2 1 accurate lock, f ref = 8-150khz, dither clk rcsys/ 2, ssg disabled (2) 0.1 1 i dfll power consumption (1) range 0 96 to 220mhz coarse=0, fine=0, div=0 430 509 545 a range 0 96 to 220mhz coarse=31, fine=255, div=0 1545 1858 1919 range 1 50 to 110mhz coarse=0, fine=0, div=0 218 271 308 range 1 50 to 110mhz coarse=31, fine=255, div=0 704 827 862 range 2 25 to 55mhz coarse=0, fine=0, div=1 140 187 226 range 2 25 to 55mhz coarse=31, fine=255, div=1 365 441 477 range 3 20 to 30mhz coarse=0, fine=0, div=1 122 174 219 range 3 20 to 30mhz coarse=31, fine=255, div=1 288 354 391
1146 42023e?sam?07/2013 atsam4l8/l4/l2 42.7.5 32khz rc oscillator (rc32k) characteristics 42.7.6 system rc oscillator (rcsys) characteristics t startup startup time (1) within 90% of final values 100 s t lock lock time (1) f ref = 32khz, fine lock, ssg disabled (2) 600 f ref = 32khz, accurate lock, dithering clock = rcsys/2, ssg disabled (2) 1100 1. these values are based on simulation. these values are no t covered by test limits in production or characterization. 2. spread spectrum generator (ssg) is disabled by writin g a zero to the en bit in the scif.dfll0ssg register. table 42-28. 32khz rc oscillator characteristics symbol parameter conditions min typ max unit f out output frequency (1) 1. these values are based on characterization. these values are not covered by test limits in production. calibrated against a 32.768khz reference temperature compensation disabled 20 32.768 44 khz i rc32k current consumption (2) 2. these values are based on simulation. these values are no t covered by test limits in production or characterization. without temperature compensation 0.5 a temperature compensation enabled 2 a t startup startup time (1) 1 cycle table 42-29. system rc oscillator characteristics symbol parameter conditions min typ max unit f out output frequency (1) 1. these values are based on characterization. these values are not covered by test limits in production. calibrated at 85 c 110 113.6 116 khz i rcsys current consumption (2) 2. these values are based on simulation. these values are no t covered by test limits in production or characterization. 12 a t startup startup time (1) 25 38 63 s duty duty cycle (1) 49.6 50 50.3 % table 42-27. digital frequency locked loop characteristics symbol parameter conditions min typ max unit
1147 42023e?sam?07/2013 atsam4l8/l4/l2 42.7.7 1mhz rc oscillator (rc1m) characteristics 42.7.8 4/8/12mhz rc oscillator (rcfast) characteristics table 42-30. rc1m oscillator characteristics symbol parameter conditions min typ max unit f out output frequency (1) 1. these values are based on characterization. these values are not covered by test limits in production. 0.91 1 1.12 mhz i rc1m current consumption (2) 2. these values are based on simulation. these values are no t covered by test limits in production or characterization. 35 a duty duty cycle (1) 48.6 49.9 54.4 % table 42-31. rcfast oscillator characteristics symbol parameter conditions min typ max unit f out output frequency (1) 1. these values are based on characterization. these values are not covered by test limits in production. calibrated, frange=0 4 4.3 4.6 mhz calibrated, frange=1 7.8 8.2 8.5 calibrated, frange=2 11.3 12 12.3 i rcfast current consumption (2) 2. these values are based on simulation. these values are no t covered by test limits in production or characterization. calibrated, frange=0 90 110 a calibrated, frange=1 130 150 calibrated, frange=2 180 205 duty duty cycle (1) calibrated, frange=0 48.8 49.6 50.1 % calibrated, frange=1 47.8 49.2 50.1 calibrated, frange=2 46.7 48.8 50.0 t startup startup time (1) calibrated, frange=2 0.1 0.31 0.71 s
1148 42023e?sam?07/2013 atsam4l8/l4/l2 42.7.9 80mhz rc oscillator (rc80m) characteristics 42.8 flash characteristics table 42-33 gives the device maximum operating frequency depending on the number of flash wait states and the flash read mode. the fws bi t in the flashcalw fcr register controls the number of wait states used wh en accessing the flash memory. table 42-32. internal 80mhz rc oscill ator characteristics symbol parameter conditions min typ max unit f out output frequency (1) 1. these values are based on characterization. these values are not covered by test limits in production. after calibration note that rc80m is not available in ps1 60 80 100 mhz i rc80m current consumption (2) 2. these values are based on simulation. these values are no t covered by test limits in production or characterization. 330 a t startup startup time (1) 0.57 1.72 3.2 s duty duty cycle (2) 45 50 55 % table 42-33. maximum operating frequency (1) powerscaling mode flash read mode flash wait states maximum operating frequency unit 0 low power (hsdis) + flash internal reference: bpm.pmcon.fastwkup=1 112 mhz low power(hsdis) 018 136 1 low power (hsdis) + flash internal reference: bpm.pmcon.fastwkup=1 112 low power (hsdis) 08 112 2 high speed (hsen) 024 148 1. these values are based on simulation. these values are no t covered by test limits in production or characterization. table 42-34. flash characteristics (1) symbol parameter conditions min typ max unit t fpp page programming time f clk_ahb = 48mhz 4.38 ms t fpe page erase time 4.38 t ffp fuse programming time 0.63 t fea full chip erase time (ea) 5.66 t fce jtag chip erase time (chip_erase) f clk_ahb = 115khz 304
1149 42023e?sam?07/2013 atsam4l8/l4/l2 1. these values are based on simulation. these values are no t covered by test limits in production or characterization. table 42-35. flash endurance and data retention (1) symbol parameter conditions min typ max unit n farray array endurance (write/page) f clk_ahb > 10mhz 100k cycles n ffuse general purpose fuses endurance (write/bit) f clk_ahb > 10mhz 10k t ret data retention 15 years 1. these values are based on simulation. these values are no t covered by test limits in production or characterization.
1150 42023e?sam?07/2013 atsam4l8/l4/l2 42.9 analog characteristics 42.9.1 voltage regulator characteristics table 42-36. vreg electrical characteristics in linear and switching modes symbol parameter conditions min typ max units i out dc output current (1) power scaling mode 0 & 2 1. these values are based on simulation. these valu es are not covered by test limits in production. low power mode (wait) 2000 3600 5600 a ultra low power mode (retention) 100 180 300 dc output current (1) power scaling mode 1 low power mode (wait) 4000 7000 10000 ultra low power mode (retention) 200 350 600 v vddcore dc output voltage all modes 1.9 v table 42-37. vreg electrical characte ristics in linear mode symbol parameter conditions min typ max units v vddin input voltage range i out =10ma 1.68 3.6 v i out =50ma 1.8 3.6 v vddcore dc output voltage (1) power scaling mode 0 & 2 1. these values are based on characterization. these values are not covered by test limits in production. i out = 0 ma 1.777 1.814 1.854 i out = 50 ma 1.75 1.79 1.83 i out dc output current (1) v vddcore > 1.65v 100 ma output dc load regulation (1) transient load regulation i out = 0 to 80ma, v vddin = 3v -34 -27 -19 mv output dc regulation (1) i out = 80 ma, v vddin = 2v to 3.6v 10 28 48 mv i q quescient current (1) i out = 0 ma run and sleepx modes 88 107 128 a table 42-38. external components requirements in linear mode symbol parameter technology typ units c in1 input regulator capacitor 1 33 nf c in2 input regulator capacitor 2 100 c in3 input regulator capacitor 3 10 f c out1 output regulator capacitor 1 100 nf c out2 output regulator capacitor 2 tantalum or mlcc 0.5 1151 42023e?sam?07/2013 atsam4l8/l4/l2 note: 1. refer to section 5. on page 42 . i out dc output current (1) v vddcore > 1.65v 55 ma output dc load regulation (1) transient load regulation i out = 0 to 50ma, v vddin = 3v -136 -101 -82 mv output dc regulation (1) i out = 50 ma, v vddin = 2v to 3.6v -20 38 99 mv i q quescient current (1) v vddin = 2v, i out = 0 ma 97 186 546 a v vddin > 2.2v, i out = 0 ma 97 111 147 p eff power efficiency (1) i out = 5ma, 50ma reference power not included 82.7 88.3 95 % 1. these values are based on characterization. these values are not covered by test limits in production. table 42-40. decoupling requirement s in switching mode symbol parameter technology typ units c in1 input regulator capacitor 1 33 nf c in2 input regulator capacitor 2 100 c in3 input regulator capacitor 3 10 f c out1 output regulator capacitor 1 x7r mlcc 100 nf c out2 output regulator capacitor 2 x7r mlcc (ex : grm31cr71a475) 4.7 f l ext external inductance (ex: murata lqh3npn220mj0) 22 h r dclext serial resistance of l ext 0.7 isat lext saturation current of l ext 300 ma table 42-39. vreg electrical characte ristics in switching mode symbol parameter conditions min typ max units
1152 42023e?sam?07/2013 atsam4l8/l4/l2 42.9.2 power-on reset 33 characteristics figure 42-4. por33 operating principle 42.9.3 brown out detectors characteristics table 42-41. por33 characteristics (1) 1. these values are based on characterization. these values are not covered by test limits in production. symbol parameter conditions min typ max units v pot+ voltage threshold on v vddin rising 1.25 1.55 v v pot- voltage threshold on v vddin falling 0.95 1.30 reset v vddin v pot+ v pot- time table 42-42. bod18 characteristics (1) symbol parameter conditions min typ max units step size, between adjacent values in bscif.bod18level (1) 10.1 mv v hyst bod hysteresis (1) t = 25 c340 t det detection time (1) time with v vddcore < bod18.level necessary to generate a reset signal 1.2 s i bod current consumption (1) on vddin 7.4 14 a on vddcore 7 t startup startup time (1) 4.5 s
1153 42023e?sam?07/2013 atsam4l8/l4/l2 the values in table 42-43 describe the values of the bod3 3.level in the flash user page fuses. 1. these values are based on simulation. these values are no t covered by test limits in production or characterization. table 42-43. bod33.level values bod33.level value min typ max units 16 2.08 v 20 2.18 24 2.33 28 2.48 32 2.62 36 2.77 40 2.92 44 3.06 48 3.21 table 42-44. bod33 characteristics (1) symbol parameter conditions min typ max units step size, between adjacent values in bscif.bod33level (1) 3.44 mv v hyst hysteresis (1) 45 170 t det detection time (1) time with vddin < v th necessary to generate a reset signal s i bod33 current consumption (1) normal mode 36 a t startup startup time (1) normal mode 6 s 1. these values are based on simulation. these values are no t covered by test limits in production or characterization.
1154 42023e?sam?07/2013 atsam4l8/l4/l2 42.9.4 analog- to digital converter characteristics figure 42-5. maximum input common mode voltage table 42-45. operating conditions symbol parameter conditions min typ max units temperature range -40 +85 c resolution (1) 1. these values are based on characterization. these values are not covered by test limits in production max 12 12 (2) 2. single ended or using divide by two max resolution: 11 bits bit sampling clock (3) 3. these values are based on simulation. these valu es are not covered by test limits in production differential modes, gain=1x 5 300 khz unipolar modes, gain=1x 5 250 f adc adc clock frequency (3) differential modes 0.03 1.8 mhz unipolar modes 0.03 1.5 t samplehold sampling time (3) differential modes 16.5 277 s unipolar modes 16.5 333 conversion rate (1) 1x gain, differential 300 ksps internal channel conversion rate (3) v vdd /10, bandgap and temperature channels 125 ksps conversion time (latency) differential mode (no windowing) 1x gain, (resolution/2)+gain (4) 4. see figure 42-5 6 cycles 2x and 4x gain 7 8x and 16x gain 8 32x and 64x gain 9 64x gain and unipolar 10 m ax in p u t co m m o n m o de v o lta g e 0 0.5 1 1.5 2 2.5 3 1.6 3.6 vcc icmr vc m _ vr ef= 3v vc m _ vr ef= 1v
1155 42023e?sam?07/2013 atsam4l8/l4/l2 table 42-46. dc characteristics symbol parameter conditions min typ max units vddana supply voltage (1) 1.6 3.6 v reference range (2) differential mode 1.0 vddana -0.6 v unipolar and window modes 1.0 1.0 using divide by two function (differential) vddana absolute min, max input voltage (2) -0,1 vddana +0.1 v start up time (2) adc with reference already enabled 12 24 cycles no gain compensation reference buffer 5s gain compensation reference buffer 60 cycles r sample input channel source resistance (2) 0.5 k c sample sampling capacitance (2) 2.9 3.6 4.3 pf reference input source resistance (2) gain compensation 2 k no gain compensation 1 m adc reference settling time (2) after changing reference/mode (3) 5 60 cycles 1. these values are based on characterization. these values are not covered by test limits in production 2. these values are based on simulation. these valu es are not covered by test limits in production 3. requires refresh/flush otherwise conversion time (latency) + 1 table 42-47. differential mode, gain=1 symbol parameter conditions min typ max units accuracy without compensation (1) 7enob accuracy after compensation (1) (inl, gain and offset) 11 enob inl integral non linearity (2) after calibration, gain compensation 1.2 1.7 lsbs dnl differential non linearity (2) after calibration 0.7 1.0 lsbs gain error (2) external reference -5.0 -1.0 5.0 mv vddana/1.6 -40 40 vddana/2.0 -40 40 bandgap after calibration -30 30 gain error drift vs voltage (1) external reference -2 2 mv/v gain error drift vs temperature (1) after calibration + bandgap drift if using onchip bandgap 0.08 mv/k offset error (2) external reference -5.0 5.0 mv vddana/1.6 -10 10 vddana/2.0 -10 10 bandgap after calibration -10 10 offset error drift vs voltage (1) -4 4 mv/v
1156 42023e?sam?07/2013 atsam4l8/l4/l2 offset error drift vs temperature (1) 0.04 mv/k conversion range (2) vin-vip -vref vref v icmr (1) see figure 42-5 psrr (1) fvdd=1hz, ext advrefp=3.0v v vdd =3.6v 100 db fvdd=2mhz, ext advrefp=3.0v v vdd =3.6 50 dc supply current (2) vddana=3.6v, advrefp=3.0v 1.2 ma vddana=1.6v, advrefp=1.0v 0.6 1. these values are based on simulation only. these values are not covered by test limits in production or characterization 2. these values are based on characterization and not tested in production, and valid for an input voltage between 10% to 90% of reference voltage. table 42-48. unipolar mode, gain=1 symbol parameter conditions min typ max units accuracy without compensation (1) 7enob accuracy after compensation (1) 11 enob inl integral non linearity (2) after calibration dynamic tests no gain compensation 3 lsbs after calibration dynamic tests gain compensation 3 dnl differential non linearity (2) after calibration 2.8 lsbs gain error (2) external reference -15 15 mv vddana/1.6 -50 50 vddana/2.0 -30 30 bandgap after calibration -10 10 gain error drift vs voltage (1) external reference -8 8 mv/v gain error drift temperature (1) + bandgap drift if using bandgap 0.08 mv/k offset error (2) external reference -15 15 mv vddana/1.6 -15 15 vddana/2.0 -15 15 bandgap after calibration -10 10 offset error drift (1) -4 4 mv/v offset error drift temperature (1) 00.04mv/k conversion range (1) vin-vip -vref vref v icmr (1) see figure 42-5 table 42-47. differential mode, gain=1
1157 42023e?sam?07/2013 atsam4l8/l4/l2 42.9.4.1 inputs and sample and hold acquisition times the analog voltage source must be able to charge the sample and hold (s/h) capacitor in the adc in order to achieve maximum accuracy. seen externally the adc input consists of a resis- tor ( ) and a capacitor ( ). in addition, the source resistance ( ) must be taken into account when calculating the required sample and hold time. figure 42-6 shows the adc input channel equivalent circuit. figure 42-6. adc input to achieve n bits of accuracy, the capacitor must be charged at least to a voltage of the minimum sampling time for a given can be found using this formula: for a 12 bits accuracy : where psrr (1) fvdd=1hz, ext advrefp=3.0v vddio=3.6v 100 db fvdd=2mhz, ext advrefp=3.0v vddio=3.6v 50 dc supply current (1) vddana=3.6v, advrefp=3.0v 11.8 ma vddana=1.6v, advrefp=1.0v 11.3 1. these values are based on simulation. these values are no t covered by test limits in production or characterization. 2. these values are based on characterization and not tested in production, and valid for an input voltage between 10% to 90% of reference voltage. table 42-48. unipolar mode, gain=1 r sample c sample r source r source r sample analog input adx c sample v in vddana/2 c sample v csample v in 12 n 1 + () ? ? () t samplehold r source t samplehold r sample r + source () c sample () n 1 + () 2 () ln t samplehold r sample r + source () c sample () 9 02 , t samplehold 1 2 fadc ----------------------- - =
1158 42023e?sam?07/2013 atsam4l8/l4/l2 42.9.5 digital to analog converter characteristics 42.9.6 analog comparator characteristics table 42-49. operating conditions symbol parameter conditions min typ max units analog supply voltage (1) 1. these values are based on simulation. these values are no t covered by test limits in production or characterization on vddana 2.4 3 3.6 v digital supply voltage (1) on vddcore 1.62 1.8 1.98 v resolution (2) 2. these values are based on characterization. these values are not covered by test limits in production 10 bits clock frequency (1) cload = 50pf ; rload = 5k 500 khz load (1) cload 50 pf rload 5 k inl integral non linearity (1) best fit-line method 2 lsbs dnl differential non linearity (1) best fit-line me thod -0.9 +1 lsbs zero error (offset) (1) cdr[9:0] = 0 1 5 mv gain error (1) cdr[9:0] = 1023 5 10 mv total harmonic distortion (1) 80% of vddana @ fin = 70khz -56 7 db delay to vout (1) cdr[9:0] = 512/ cload = 50 pf / rload = 5 k 2s startup time (1) cdr[9:0] = 512 5 9 s output voltage range (advrefp < vddana ? 100mv) is mandatory 0 advrefp v advrefp voltage range (1) (advrefp < vddana ? 100mv) is mandatory 2.3 3.5 v advrefn voltage range (1) advrefp = gnd 0 v standby current (1) on vddana 500 na on vddcore 100 dc current consumption (1) on vddana (no rload) 485 660 a on advrefp (cdr[9:0] = 512) 250 295 table 42-50. analog comparator characteristics symbol parameter conditions min typ max units positive input voltage range 0.1 vddio-0.1 v negative input voltage range 0.1 vddio-0.1 offset (1) v acrefn =0.1v to vddio-0.1v, hysteresis = 0 (2) fast mode -12 13 mv v acrefn =0.1v to vddio-0.1v, hysteresis = 0 (2) low power mode -11 12 mv
1159 42023e?sam?07/2013 atsam4l8/l4/l2 hysteresis (1) v acrefn =0.1v to vddio-0.1v, hysteresis = 1 (2) fast mode 10 55 mv v acrefn =0.1v to vddio-0.1v, hysteresis = 1 (2) low power mode 10 68 mv v acrefn =0.1v to vddio-0.1v, hysteresis = 2 (2) fast mode 26 83 mv v acrefn =0.1v to vddio-0.1v, hysteresis = 2 (2) low power mode 19 91 mv v acrefn =0.1v to vddio-0.1v, hysteresis = 3 (2) fast mode 43 106 mv v acrefn =0.1v to vddio-0.1v, hysteresis = 3 (2) low power mode 32 136 mv propagation delay (1) changes for v acm =vddio/2 100mv overdrive fast mode 67 ns changes for v acm =vddio/2 100mv overdrive low power mode 315 ns t startup startup time (1) enable to ready delay fast mode 1.19 s enable to ready delay low power mode 3.61 s i ac channel current consumption (3) low power mode, no hysteresis 4.9 8.7 a fast mode, no hysteresis 63 127 1. these values are based on characterization. these values are not covered by test limits in production 2. hystac.confn.hys field, refer to the analog comparator interface chapter 3. these values are based on simulation. these values are no t covered by test limits in production or characterization table 42-50. analog comparator characteristics symbol parameter conditions min typ max units
1160 42023e?sam?07/2013 atsam4l8/l4/l2 42.9.7 liquid crystal display controler characteristics 42.9.7.1 liquid crystal controler supply current the values in table 42-52 are measured values of power consumption under the following con- ditions, except where noted: ? t=25c, wait mode, low power waveform, frame rate = 32hz from osc32k ? configuration: 4comx40seg, 1/4 duty, 1/3 bias, no animation ? all segments on, load = 160 x 22pf between each com and each seg. ? lcdca current based on i lcd = i wait (lcd on) - i wait (lcd off) table 42-51. liquid crystal display co ntroler characteristics symbol parameter conditions min typ max units seg segment terminal pins 40 com common terminal pins 4 f frame lcd frame frequency f clklcd 31.25 512 hz c flying flying capacitor 100 nf v lcd lcd regulated voltages (1) cfg.fcst=0 1. these values are based on simulation. these values are no t covered by test limits in production or characterization c flying = 100nf 100nf on v lcd , bias2 and bias1 pins 3 v bias2 2*v lcd /3 bias1 v lcd /3 table 42-52. liquid crystal display controler supply current symbol conditions min typ max units i lcd internal voltage generation cfg.fcst=0 v vddin = 3.6v 8.85 a v vddin = 1.8v 6.16 external bias v lcd =3.0v v vddin = 3.3v 0.98 v vddin = 1.8v 1.17
1161 42023e?sam?07/2013 atsam4l8/l4/l2 42.10 timing characteristics 42.10.1 reset_n timing 42.10.2 usart in spi mode timing 42.10.2.1 master mode figure 42-7. usart in spi master mode with (cpo l= cpha= 0) or (cpol= cpha= 1) figure 42-8. usart in spi master mode with (cpol= 0 and cpha= 1) or (cpol= 1 and cpha= 0) table 42-53. reset_n waveform parameters (1) 1. these values are based on simulation. these valu es are not covered by test limits in production. symbol parameter conditions min max units t reset reset_n minimum pulse length 10 ns uspi0 uspi1 miso spck mosi uspi2 uspi3 uspi4 miso spck mosi uspi5
1162 42023e?sam?07/2013 atsam4l8/l4/l2 notes: 1. these values are based on simulation. these va lues are not covered by test limits in production. 2. where: table 42-54. usart0 in spi mode timing, master mode (1) symbol parameter conditions min max units uspi0 miso setup time before spck rises v vddio from 3.0v to 3.6v, maximum external capacitor = 40pf 123.2 + t sample (2) ns uspi1 miso hold time after spck rises 24.74 -t sample (2) uspi2 spck rising to mosi delay 513.56 uspi3 miso setup time befo re spck falls 125.99 + t sample (2) uspi4 miso hold time after spck falls 24.74 -t sample (2) uspi5 spck falling to mosi delay 516.55 table 42-55. usart1 in spi mode timing, master mode (1) symbol parameter conditions min max units uspi0 miso setup time before spck rises v vddio from 3.0v to 3.6v, maximum external capacitor = 40pf 69.28 + t sample (2) ns uspi1 miso hold time after spck rises 25.75 -t sample (2) uspi2 spck rising to mosi delay 99.66 uspi3 miso setup time be fore spck falls 73.12 + t sample (2) uspi4 miso hold time after spck falls 28.10 -t sample (2) uspi5 spck falling to mosi delay 102.01 table 42-56. usart2 in spi mode timing, master mode (1) symbol parameter conditions min max units uspi0 miso setup time before spck rises v vddio from 3.0v to 3.6v, maximum external capacitor = 40pf 69.09 + t sample (2) ns uspi1 miso hold time after spck rises 26.52 -t sample (2) uspi2 spck rising to mosi delay 542.96 uspi3 miso setup time be fore spck falls 72.55 + t sample (2) uspi4 miso hold time after spck falls 28.37 -t sample (2) uspi5 spck falling to mosi delay 544.80 table 42-57. usart3 in spi mode timing, master mode (1) symbol parameter conditions min max units uspi0 miso setup time before spck rises v vddio from 3.0v to 3.6v, maximum external capacitor = 40pf 147.24 + t sample (2) ns uspi1 miso hold time after spck rises 25.80 -t sample (2) uspi2 spck rising to mosi delay 88.23 uspi3 miso setup time be fore spck falls 154.9 + t sample (2) uspi4 miso hold time after spck falls 26.89 -t sample (2) uspi5 spck falling to mosi delay 89.32 t sample t spck t spck 2 t clkusart ------------------------------------ 1 2 -- - ?? ?? t clkusart ? =
1163 42023e?sam?07/2013 atsam4l8/l4/l2 maximum spi frequency, master output the maximum spi master output frequenc y is given by the following formula: where is the mosi delay, uspi2 or uspi5 depending on cpol and ncpha. is the maximum frequency of the spi pins. refer to the i/o pin characteristics section for the maxi- mum frequency of the pins. is the maximum frequency of the clk_spi. refer to the spi chapter for a description of this clock. maximum spi frequency, master input the maximum spi master input frequenc y is given by the following formula: where is the miso setup and hold time, uspi0 + uspi1 or uspi3 + uspi4 depending on cpol and ncpha. is the spi slave response time. refer to the spi slave datasheet for . is the maximum frequency of the clk_spi. refer to the spi chapter for a description of this clock. 42.10.2.2 slave mode figure 42-9. usart in spi slave mode with (cpol= 0 and cpha= 1) or (cpol= 1 and cpha= 0) f spckmax min f pinmax 1 spin ------------ f clkspi 2 9 ---------------------------- - , (, ) = spin f pinmax f clkspi f spckmax min 1 spin t valid + ----------------------------------- - f clkspi 2 9 ---------------------------- - (,) = spin t valid t valid f clkspi uspi7 uspi8 miso spck mosi uspi6
1164 42023e?sam?07/2013 atsam4l8/l4/l2 figure 42-10. usart in spi slave mode with (cpol= cpha= 0) or (cpol= cpha= 1) figure 42-11. usart in spi slave mode, npcs timing uspi10 uspi11 miso spck mosi uspi9 uspi14 uspi12 uspi15 uspi13 nss spck, cpol=0 spck, cpol=1 table 42-58. usart0 in spi mode timing, slave mode (1) symbol parameter conditions min max units uspi6 spck falling to miso delay v vddio from 3.0v to 3.6v, maximum external capacitor = 40pf 740.67 ns uspi7 mosi setup time before spck rises 56.73 + t sample (2) + t clk_usart uspi8 mosi hold time after spck rises 45.18 -( t sample (2) + t clk_usart ) uspi9 spck rising to miso delay 670.18 uspi10 mosi setup time before spck falls 56.73 +( t sample (2) + t clk_usart ) uspi11 mosi hold time after spck falls 45.18 -( t sample (2) + t clk_usart ) uspi12 nss setup time before spck rises 688.71 uspi13 nss hold time after spck falls -2.25 uspi14 nss setup time before spck falls 688.71 uspi15 nss hold time after spck rises -2.25
1165 42023e?sam?07/2013 atsam4l8/l4/l2 table 42-59. usart1 in spi mode timing, slave mode (1) symbol parameter conditions min max units uspi6 spck falling to miso delay v vddio from 3.0v to 3.6v, maximum external capacitor = 40pf 373.58 ns uspi7 mosi setup time before spck rises 4.16 + t sample (2) + t clk_usart uspi8 mosi hold time after spck rises 46.69 -( t sample (2) + t clk_usart ) uspi9 spck rising to miso delay 373.54 uspi10 mosi setup time before spck falls 4.16 +( t sample (2) + t clk_usart ) uspi11 mosi hold time after spck falls 46.69 -( t sample (2) + t clk_usart ) uspi12 nss setup time before spck rises 200.43 uspi13 nss hold time after spck falls -16.5 uspi14 nss setup time before spck falls 200.43 uspi15 nss hold time after spck rises -16.5 table 42-60. usart2 in spi mode timing, slave mode (1) symbol parameter conditions min max units uspi6 spck falling to miso delay v vddio from 3.0v to 3.6v, maximum external capacitor = 40pf 770.02 ns uspi7 mosi setup time before spck rises 136.56 + t sample (2) + t clk_usart uspi8 mosi hold time after spck rises 47.9 -( t sample (2) + t clk_usart ) uspi9 spck rising to miso delay 570.19 uspi10 mosi setup time before spck falls 136.73 +( t sample (2) + t clk_usart ) uspi11 mosi hold time after spck falls 47.9 -( t sample (2) + t clk_usart ) uspi12 nss setup time before spck rises 519.87 uspi13 nss hold time after spck falls -1.83 uspi14 nss setup time before spck falls 519.87 uspi15 nss hold time after spck rises -1.83
1166 42023e?sam?07/2013 atsam4l8/l4/l2 notes: 1. these values are based on simulation. these va lues are not covered by test limits in production. 2. where: maximum spi frequency, slave input mode the maximum spi slave input frequency is given by the following formula: where is the mosi setup and hold time, uspi7 + uspi8 or uspi10 + uspi11 depending on cpol and ncpha. is the maximum frequency of the clk_spi. refer to the spi chapter for a description of this clock. maximum spi frequency, slave output mode the maximum spi slave output frequency is given by the following formula: where is the miso delay, uspi6 or uspi9 depending on cpol and ncpha. is the spi master setup time. refer to the spi master datasheet for . is the maxi- mum frequency of the clk_spi. refer to the spi chapter for a description of this clock. is the maximum frequency of the spi pins. refer to the i/o pin characteristics section for the maximum frequency of the pins. table 42-61. usart3 in spi mode timing, slave mode (1) symbol parameter conditions min max units uspi6 spck falling to miso delay v vddio from 3.0v to 3.6v, maximum external capacitor = 40pf 593.9 ns uspi7 mosi setup time before spck rises 45.93 + t sample (2) + t clk_usart uspi8 mosi hold time after spck rises 47.03 -( t sample (2) + t clk_usart ) uspi9 spck rising to miso delay 593.38 uspi10 mosi setup time before spck falls 45.93 +( t sample (2) + t clk_usart ) uspi11 mosi hold time after spck falls 47.03 -( t sample (2) + t clk_usart ) uspi12 nss setup time before spck rises 237.5 uspi13 nss hold time after spck falls -1.81 uspi14 nss setup time before spck falls 237.5 uspi15 nss hold time after spck rises -1.81 t sample t spck t spck 2 t clkusart ------------------------------------ 1 2 -- - + ?? ?? t clkusart ? = f spckmax min f clkspi 2 9 ---------------------------- - 1 spin ------------ (,) = spin f clkspi f spckmax min f clkspi 2 9 ---------------------------- - f pinmax , 1 spin t setup + ------------------------------------ (,) = spin t setup t setup f clkspi f pinmax
1167 42023e?sam?07/2013 atsam4l8/l4/l2 42.10.3 spi timing 42.10.3.1 master mode figure 42-12. spi master mode with (cpol= nc pha= 0) or (cpol= ncpha= 1) figure 42-13. spi master mode with (cpol= 0 and ncpha= 1) or (cpol= 1 and ncpha= 0) note: 1. these values are based on simulation. these val ues are not covered by test limits in production. maximum spi frequency, master output spi0 spi1 miso spck mosi spi2 spi3 spi4 miso spck mosi spi5 table 42-62. spi timing, master mode (1) symbol parameter conditions min max units spi0 miso setup time before spck rises v vddio from 3.0v to 3.6v, maximum external capacitor = 40pf 72.8 + (t clk_spi )/2 ns spi1 miso hold time after spck rises 22.7 spi2 spck rising to mosi delay 47.4 spi3 miso setup time befo re spck falls 76.5 + (t clk_spi )/2 spi4 miso hold time after spck falls 20.6 spi5 spck falling to mosi delay 49.5
1168 42023e?sam?07/2013 atsam4l8/l4/l2 the maximum spi master output frequenc y is given by the following formula: where is the mosi delay, spi2 or spi5 depending on cpol and ncpha. is the maximum frequency of the spi pins. refer to the i/o pin characteristics section for the maximum frequency of the pins. maximum spi frequency, master input the maximum spi master input frequenc y is given by the following formula: where is the miso setup and hold time, spi0 + spi1 or spi3 + spi4 depending on cpol and ncpha. is the spi slave response time. refer to the spi slave datasheet for . 42.10.3.2 slave mode figure 42-14. spi slave mode with (cpol= 0 and ncpha= 1) or (cpol= 1 and ncpha= 0) figure 42-15. spi slave mode with (cpol= ncp ha= 0) or (cpol= ncpha= 1) f spckmax min f pinmax 1 spin ------------ (,) = spin f pinmax f spckmax 1 spin t valid + ----------------------------------- - = spin t valid t valid spi7 spi8 miso spck mosi spi6 spi10 spi11 miso spck mosi spi9
1169 42023e?sam?07/2013 atsam4l8/l4/l2 figure 42-16. spi slave mode, npcs timing note: 1. these values are based on simulation. these val ues are not covered by test limits in production. maximum spi frequency, slave input mode the maximum spi slave input frequency is given by the following formula: where is the mosi setup and hold time, spi7 + spi8 or spi10 + spi11 depending on cpol and ncpha. is the maximum frequency of the clk_spi. refer to the spi chap- ter for a description of this clock. maximum spi frequency, slave output mode the maximum spi slave output frequency is given by the following formula: spi14 spi12 spi15 spi13 npcs spck, cpol=0 spck, cpol=1 table 42-63. spi timing, slave mode (1) symbol parameter conditions min max units spi6 spck falling to miso delay v vddio from 3.0v to 3.6v, maximum external capacitor = 40pf 79 ns spi7 mosi setup time before spck rises 2.1 spi8 mosi hold time after spck rises 7.3 spi9 spck rising to miso delay 80 spi10 mosi setup time before spck falls 1 spi11 mosi hold time after spck falls 6 spi12 npcs setup time before spck rises 4 spi13 npcs hold time after spck falls 1 spi14 npcs setup time before spck falls 4.1 spi15 npcs hold time after spck rises 1.4 f spckmax min f clkspi 1 spin ------------ (,) = spin f clkspi f spckmax min f pinmax 1 spin t setup + ------------------------------------ (, ) =
1170 42023e?sam?07/2013 atsam4l8/l4/l2 where is the miso delay, spi6 or spi9 depending on cpol and ncpha. is the spi master setup time. refer to the spi master datasheet for . is the maximum frequency of the spi pins. refer to the i/o pin characteristics section for the maximum frequency of the pins. 42.10.4 twim/twis timing figure 42-64 shows the twi-bus timing requirements and the compliance of the device with them. some of these requirements (t r and t f ) are met by the device without requiring user inter- vention. compliance with the other requirements (t hd-sta , t su-sta , t su-sto , t hd-dat , t su-dat-twi , t low- twi , t high , and f twck ) requires user intervention through appropriate programming of the relevant twim and twis user interface registers. refer to the twim and twis sections for more information. notes: 1. standard mode: ; fast mode: . spin t setup t setup f pinmax table 42-64. twi-bus timing requirements symbol parameter mode minimum maximum unit requirement device requirement device t r twck and twd rise time standard (1) - 1000 ns fast (1) 20 + 0.1c b 300 t f twck and twd fall time standard - 300 ns fast 20 + 0.1c b 300 t hd-sta (repeated) start hold time standard 4 t clkpb - s fast 0.6 t su-sta (repeated) start set-up time standard 4.7 t clkpb - s fast 0.6 t su-sto stop set-up time standard 4.0 4t clkpb - s fast 0.6 t hd-dat data hold time standard 0.3 (2) 2t clkpb 3.45 () 15t prescaled + t clkpb s fast 0.9 () t su-dat-twi data set-up time standard 250 2t clkpb -ns fast 100 t su-dat --t clkpb -- t low-twi twck low period standard 4.7 4t clkpb - s fast 1.3 t low --t clkpb -- t high twck high period standard 4.0 8t clkpb - s fast 0.6 f twck twck frequency standard - 100 khz fast 400 1 12t clkpb ----------------------- - f twck 100 khz f twck 100 khz >
1171 42023e?sam?07/2013 atsam4l8/l4/l2 2. a device must internally provide a hold time of at least 300 ns for twd with reference to the falling edge of twck. notations: c b = total capacitance of one bus line in pf t clkpb = period of twi peripheral bus clock t prescaled = period of twi internal prescaled clock (see chapters on twim and twis) the maximum t hd;dat has only to be met if the device does not stretch the low period (t low-twi ) of twck. 42.10.5 jtag timing figure 42-17. jtag interface signals jtag2 jtag3 jtag1 jtag4 jtag0 tms/tdi tck tdo jtag5 jtag6 jtag7 jtag8 jtag9 jtag10 boundary scan inputs boundary scan outputs
1172 42023e?sam?07/2013 atsam4l8/l4/l2 note: 1. these values are based on simulation. these val ues are not covered by test limits in production. 42.10.6 swd timing figure 42-18. swd interface signals table 42-65. jtag timings (1) symbol parameter conditions min max units jtag0 tck low half-period v vddio from 3.0v to 3.6v, maximum external capacitor = 40pf 21.8 ns jtag1 tck high half-period 8.6 jtag2 tck period 30.3 jtag3 tdi, tms setup before tck high 2.0 jtag4 tdi, tms hold after tck high 2.3 jtag5 tdo hold time 9.5 jtag6 tck low to tdo valid 21.8 jtag7 boundary scan inputs setup time 0.6 jtag8 boundary scan inputs hold time 6.9 jtag9 boundary scan outputs hold time 9.3 jtag10 tck to boundary scan outputs valid 32.2 stop park tri state acknowledge tri state tri state parity start data data stop park tri state acknowledge tri state start read cycle write cycle tos thigh tlow tis data data parity tri state tih from debugger to swdio pin from debugger to swdclk pin swdio pin to debugger from debugger to swdio pin from debugger to swdclk pin swdio pin to debugger
1173 42023e?sam?07/2013 atsam4l8/l4/l2 note: 1. these values are based on simulation. these values are not covered by test limits in production or characterization. table 42-66. swd timings (1) symbol parameter conditions min max units thigh swdclk high period v vddio from 3.0v to 3.6v, maximum external capacitor = 40pf 10 500 000 ns tlow swdclk low period 10 500 000 tos swdio output skew to falling edge swdclk -5 5 tis input setup time required between swdio 4 - tih input hold time required between swdio and rising edge swdclk 1-
1174 42023e?sam?07/2013 atsam4l8/l4/l2 43. mechanical characteristics 43.1 thermal considerations 43.1.1 thermal data table 43-1 summarizes the thermal resistance data depending on the package. 43.1.2 junction temperature the average chip-junction temperature, t j , in c can be obtained from the following: 1. 2. where: ? ja = package thermal resistance, junction-to-ambient (c/w), provided in table 43-1 . ? jc = package thermal resistance, junction-to-ca se thermal resistance (c/w), provided in table 43-1 . ? heat sink = cooling device thermal resistance (c/w), provided in the device datasheet. ?p d = device power consumption (w) estimated from data provided in section 42.5 on page 1124 . ?t a = ambient temperature (c). from the first equation, the user can derive the estimated lifetime of the chip and decide if a cooling device is necessary or not. if a coolin g device is to be fitted on the chip, the second equation should be used to compute the resulting average chip-junction temperature t j in c. table 43-1. thermal resistance data symbol parameter condition package typ unit ja junction-to-ambient thermal resistance still air tqfp100 48.1 ? c/w jc junction-to-case thermal resistance tqfp100 13.3 ja junction-to-ambient thermal resistance still air vfbga100 31.1 ? c/w jc junction-to-case thermal resistance vfbga100 6.9 ja junction-to-ambient thermal resistance still air wlcsp64 26.9 ? c/w jc junction-to-case thermal resistance wlcsp64 0.2 ja junction-to-ambient thermal resistance still air tqfp64 49.6 ? c/w jc junction-to-case thermal resistance tqfp64 13.5 ja junction-to-ambient thermal resistance still air qfn64 22.0 ? c/w jc junction-to-case thermal resistance qfn64 1.3 ja junction-to-ambient thermal resistance still air tqfp48 51.1 ? c/w jc junction-to-case thermal resistance tqfp48 13.7 ja junction-to-ambient thermal resistance still air qfn48 24.9 ? c/w jc junction-to-case thermal resistance qfn48 1.3 t j t a p d ja () + = t j t a p ( d ( heatsink jc )) ++ =
1175 42023e?sam?07/2013 atsam4l8/l4/l2 43.2 package drawings figure 43-1. vfbga-100 package drawing table 43-2. device and package maximum weight 120 mg table 43-3. package characteristics moisture sensitivity level msl3 table 43-4. package reference jedec drawing reference n/a jesd97 classification e1
1176 42023e?sam?07/2013 atsam4l8/l4/l2 figure 43-2. tqfp-100 package drawing table 43-5. device and package maximum weight 500 mg table 43-6. package characteristics moisture sensitivity level msl3 table 43-7. package reference jedec drawing reference ms-026 jesd97 classification e3
1177 42023e?sam?07/2013 atsam4l8/l4/l2 figure 43-3. wlcsp64 sam4lc4/2 package drawing table 43-8. device and package maximum weight 14.8 mg table 43-9. package characteristics moisture sensitivity level msl3 table 43-10. package reference jedec drawing reference ms-026 jesd97 classification e1
1178 42023e?sam?07/2013 atsam4l8/l4/l2 figure 43-4. wlcsp64 sam4ls4/2 package drawing table 43-11. device and package maximum weight 14.8 mg table 43-12. package characteristics moisture sensitivity level msl3 table 43-13. package reference jedec drawing reference ms-026 jesd97 classification e1
1179 42023e?sam?07/2013 atsam4l8/l4/l2 figure 43-5. tqfp-64 package drawing table 43-14. device and package maximum weight 300 mg table 43-15. package characteristics moisture sensitivity level msl3 table 43-16. package reference jedec drawing reference ms-026 jesd97 classification e3
1180 42023e?sam?07/2013 atsam4l8/l4/l2 figure 43-6. qfn-64 package drawing note: the exposed pad is not connected to anything internally, but should be soldered to ground to increase board level reliabil ity. table 43-17. device and package maximum weight 200 mg table 43-18. package characteristics moisture sensitivity level msl3 table 43-19. package reference jedec drawing reference mo-220 jesd97 classification e3
1181 42023e?sam?07/2013 atsam4l8/l4/l2 figure 43-7. tqfp-48 (atsam4lc4/2 and atsam4ls4/2 only) package drawing table 43-20. device and package maximum weight 140 mg table 43-21. package characteristics moisture sensitivity level msl3 table 43-22. package reference jedec drawing reference ms-026 jesd97 classification e3
1182 42023e?sam?07/2013 atsam4l8/l4/l2 figure 43-8. qfn-48 package drawing for atsam4lc4/2 and atsam4ls4/2 note: the exposed pad is not connected to anything internally, but should be soldered to ground to increase board level reliabil ity. table 43-23. device and package maximum weight 140 mg table 43-24. package characteristics moisture sensitivity level msl3 table 43-25. package reference jedec drawing reference mo-220 jesd97 classification e3
1183 42023e?sam?07/2013 atsam4l8/l4/l2 figure 43-9. qfn-48 package drawing for atsam4lc8 and atsam4ls8 note: the exposed pad is not connected to anything internally, but should be soldered to ground to increase board level reliabil ity. table 43-26. device and package maximum weight 140 mg table 43-27. package characteristics moisture sensitivity level msl3 table 43-28. package reference jedec drawing reference mo-220 jesd97 classification e3
1184 42023e?sam?07/2013 atsam4l8/l4/l2 43.3 soldering profile table 43-29 gives the recommended soldering profile from j-std-20. a maximum of three reflow passes is allowed per component. table 43-29. soldering profile profile feature green package average ramp-up rate (217c to peak) 3c/s max preheat temperature 175c 25c 150-200c time maintained above 217c 60-150 s time within 5 ? c of actual peak temperature 30 s peak temperature range 260c ramp-down rate 6c/s max time 25 ? c to peak temperature 8 minutes max
1185 42023e?sam?07/2013 atsam4l8/l4/l2 44. ordering information table 44-1. atsam4lc8 sub serie ordering information ordering code flash (kbytes) ram (kbytes) package conditioning package type temperature operating range atsam4lc8ca-au 512 64 tqfp100 tr ay green industrial -40c to 85c atsam4lc8ca-aur reel atsam4lc8ca-cfu vfbga100 tr ay atsam4lc8ca-cfur reel atsam4lc8ba-au tqfp64 tr ay atsam4lc8ba-aur reel atsam4lc8ba-mu qfn64 tr ay atsam4lc8ba-mur reel atsam4lc8aa-mu qfn48 tr ay atsam4lc8aa-mur reel table 44-2. atsam4lc4 sub serie ordering information ordering code flash (kbytes) ram (kbytes) package conditioning package type temperature operating range atsam4lc4ca-au-es 256 32 tqfp100 es green n/a atsam4lc4ca-au tray industrial -40c to 85c atsam4lc4ca-aur reel atsam4lc4ca-cfu vfbga100 tr ay industrial -40c to 85c atsam4lc4ca-cfur reel atsam4lc4ba-au-es tqfp64 es n/a atsam4lc4ba-au tray industrial -40c to 85c atsam4lc4ba-aur reel atsam4lc4ba-mu-es qfn64 es n/a atsam4lc4ba-mu tray industrial -40c to 85c atsam4lc4ba-mur reel atsam4lc4ba-uur wlcsp64 reel industrial -40c to 85c atsam4lc4aa-au-es tqfp48 es n/a atsam4lc4aa-au tray industrial -40c to 85c atsam4lc4aa-aur reel atsam4lc4aa-mu-es qfn48 es n/a atsam4lc4aa-mu tray industrial -40c to 85c atsam4lc4aa-mur reel
1186 42023e?sam?07/2013 atsam4l8/l4/l2 table 44-3. atsam4lc2 sub serie ordering information ordering code flash (kbytes) ram (kbytes) package conditioning package type temperature operating range atsam4lc2ca-au 128 32 tqfp100 tr ay green industrial -40c to 85c atsam4lc2ca-aur reel atsam4lc2ca-cfu vfbga100 tr ay atsam4lc2ca-cfur reel atsam4lc2ba-au tqfp64 tr ay atsam4lc2ba-aur reel atsam4lc2ba-mu qfn64 tr ay atsam4lc2ba-mur reel atsam4lc2ba-uur wlcsp64 reel atsam4lc2aa-au tqfp48 tr ay atsam4lc2aa-aur reel atsam4lc2aa-mu qfn48 tr ay atsam4lc2aa-mur reel table 44-4. atsam4ls8 sub serie or dering information ordering code flash (kbytes) ram (kbytes) package conditioning package type temperature operating range atsam4ls8ca-au 512 64 tqfp100 tr ay green industrial -40c to 85c atsam4ls8ca-aur reel atsam4ls8ca-cfu vfbga100 tr ay atsam4ls8ca-cfur reel atsam4ls8ba-au tqfp64 tr ay atsam4ls8ba-aur reel atsam4ls8ba-mu qfn64 tr ay atsam4ls8ba-mur reel atsam4ls8aa-mu qfn48 tr ay atsam4ls8aa-mur reel
1187 42023e?sam?07/2013 atsam4l8/l4/l2 table 44-5. atsam4ls4 sub serie or dering information ordering code flash (kbytes) ram (kbytes) package conditioning package type temperature operating range atsam4ls4ca-au-es 256 32 tqfp100 es green n/a atsam4ls4ca-au tray industrial -40c to 85c atsam4ls4ca-aur reel atsam4ls4ca-cfu vfbga100 tr ay industrial -40c to 85c atsam4ls4ca-cfur reel atsam4ls4ba-au-es tqfp64 es n/a atsam4ls4ba-au tray industrial -40c to 85c atsam4ls4ba-aur reel atsam4ls4ba-mu-es qfn64 es n/a atsam4ls4ba-mu tray industrial -40c to 85c atsam4ls4ba-mur reel atsam4ls4ba-uur wlcsp64 reel industrial -40c to 85c atsam4ls4aa-au-es tqfp48 es n/a atsam4ls4aa-au tray industrial -40c to 85c atsam4ls4aa-aur reel atsam4ls4aa-mu-es qfn48 es n/a atsam4ls4aa-mu tray industrial -40c to 85c atsam4ls4aa-mur reel table 44-6. atsam4ls2 sub serie or dering information ordering code flash (kbytes) ram (kbytes) package conditioning package type temperature operating range atsam4ls2ca-au 128 32 tqfp100 tr ay green industrial -40c to 85c atsam4ls2ca-aur reel atsam4ls2ca-cfu vfbga100 tr ay atsam4ls2ca-cfur reel atsam4ls2ba-au tqfp64 tr ay atsam4ls2ba-aur reel atsam4ls2ba-mu qfn64 tr ay atsam4ls2ba-mur reel atsam4ls2ba-uur wlcsp64 reel atsam4ls2aa-au tqfp48 tr ay atsam4ls2aa-aur reel atsam4ls2aa-mu qfn48 tr ay atsam4ls2aa-mur reel
1188 42023e?sam?07/2013 atsam4l8/l4/l2 45. errata 45.1 atsam4l4 /2 rev. b & atsam4l8 rev. a 45.1.1 general ps2 mode is not supported by engineering samples ps2 mode support is supported only by part s with calibration version higher than 0. fix/workaround the calibration version can be checked by re ading a 32-bit word at address 0x0080020c. the calibration version bitfield is 4-bit wide and located from bit 4 to bit 7 in this word. any value higher than 0 ensures that the part supports the ps2 mode 45.1.2 scif pllcount value larger than zero can cause pllen glitch initializing the pllcount with a value greater than zero creates a glitch on the pllen sig- nal during asynchronous wake up. fix/workaround the lock-masking mechanism for the pll should not be used. the pllcount field of the pll control register should always be written to zero. 45.1.3 wdt wdt control register does not have synchronization feedback when writing to the timeout pr escale select (psel), time ban prescale select (tban), enable (en), or wdt mode (mode) fieldss of the wdt control register (ctrl), a synchro- nizer is started to propagate the values to the wdt clcok domain. this synchronization takes a finite amount of time, but only the status of the synchronization of the en bit is reflected back to the user. writing to the synch ronized fields during synchronization can lead to undefined behavior. fix/workaround -when writing to the affected fields, the user must ensure a wait corresponding to 2 clock cycles of both the wdt peripheral bus clock and the selected wdt clock source. -when doing writes that changes the en bit, the en bit can be read back until it reflects the written value. 45.1.4 spi spi data transfer hangs with csr0.csaat==1 and mr.modfdis==0 when csr0.csaat==1 and mode fault detection is enabled (mr.modfdis==0), the spi module will not start a data transfer. fix/workaround disable mode fault detection by writing a one to mr.modfdis. spi disable does not work in slave mode spi disable does not work in slave mode.
1189 42023e?sam?07/2013 atsam4l8/l4/l2 fix/workaround read the last received data, then perform a software reset by writing a one to the software reset bit in the control register (cr.swrst). disabling spi has no effect on the sr.tdre bit disabling spi has no effect on the sr.tdre bit whereas the write data command is filtered when spi is disabled. writing to tdr when spi is disabled will not clear sr.tdre. if spi is disabled during a pdca transfer, the pdca will continue to write data to tdr until its buffer is empty, and this data will be lost. fix/workaround disable the pdca, add two nops, and disable the spi. to continue the transfer, enable the spi and pdca. spi bad serial clock generation on 2nd chip_select when scbr=1, cpol=1, and ncpha=0 when multiple chip selects (cs) are in use, if one of the baudrates equal 1 while one (csrn.scbr=1) of the others do not equal 1, and csrn.cpol=1 and csrn.ncpha=0, then an additional pulse will be genera ted on sck. fix/workaround when multiple cs are in use, if one of the baudrates equals 1, the others must also equal 1 if csrn.cpol=1 and csrn.ncpha=0. 45.1.5 tc channel chaining skips first pulse for upper channel when chaining two channels using the block mode register, the first pulse of the clock between the channels is skipped. fix/workaround configure the lower channel with ra = 0x1 and rc = 0x2 to produce a dummy clock cycle for the upper channel. after the dummy cycle has been generated, indicated by the sr.cpcs bit, reconfigure the ra and rc registers for the lower channel with the real values. 45.1.6 usbc in usb host mode, entering suspend mode for low speed device can fail when the usb freeze (usbcon.frzclk=1) is done just after uhcon.sofe=0. fix/workaround when entering suspend mode (uhcon.sofe is cleared), check that usbfsm.drdstate is not equal to three before freezing the clock (usbcon.frzclk=1). in usb host mode, the asynchronous attach detection (udint.hwupi) can fail when the usb clock freeze (usbcon.frzclk=1) is done just after setting the usb- sta.vbusrq bit. fix/workaround after setting usbsta.vbusrq bit, wait until the usbfsm register value is ?a_wait_bcon? before setting the usbcon.frzclk bit.
1190 42023e?sam?07/2013 atsam4l8/l4/l2 45.1.7 flashcalw corrupted data in flash may happen after flash page write operations. after a flash page write operation, reading (data read or code fetch) in flash may fail. this may lead to an expecption or to others errors derived from this corrupted read access. fix/workaround before any flash page write operation, each 64-bit doublewords write in the page buffer must preceded by a 64-bit doublewords write in the page buffer with 0xffffffff_ffffffff content at any address in the page. note that special care is required when loading page buffer, refer to section 14.5.8 ?page buffer operations? on page 270 .
1191 42023e?sam?07/2013 atsam4l8/l4/l2 46. datasheet revision history note that the referring page numbers in this section are referred to this document. the referring revision in this section are referring to the document revision. 46.1 rev. a ? 09/12 46.2 rev. b ? 10/12 46.3 rev. c ? 02/13 46.4 rev. d ? 03/13 1. initial revision. 1. fixed ordering code 2. changed bod18ctrl and bod33ctrl action field from ?reserved? to ?no action? 1. fixed ball pitch for vfbga100 package 2. added vfbga100 and wlcsp64 pinouts 3. added power scaling mode 2 for high frequency support 4. minor update on several modules chapters 5. major update on electrical characteristics 6. updated errata 7. fixed gpio multiplexing pin numbers 1. removed wlcsp package information 2. added errata text for detecting whether a part supports ps2 mode or not 3. removed temperature sensor feature (not supported by production flow) 4. fixed mux selection on positive adc input channel table 5. added information about twi instances capabilities 6. added some details on errata corrupted data in flash may happen after flash page write operations.1190
1192 42023e?sam?07/2013 atsam4l8/l4/l2 46.5 rev. e ? 07/13 1. added atsam4l8 derivatives and wlcsp packages for atsam4l4/2 2. added operating conditions details in electrical characteristics chapter 3. fixed ?supply rise rates and order? 4. added number of usart available in sub-series 5. fixed io line considerations for usb pins 6. removed useless information about cpu local bus which is not implemented 7. removed useless information about modem support which is not implemented 8. added information about unsupported features in power scaling mode 1 9. fixed spi timings
1193 42023e?sam?07/2013 atsam4l8/l4/l2 table of contents summary............... ................ .............. ............... .............. .............. ............ 1 features ................ ................ .............. ............... .............. .............. ............ 1 1 description ............ .............. .............. ............... .............. .............. ............ 3 2 overview ............ ................ ................ ............... .............. .............. ............ 5 2.1 block diagram ...................................................................................................5 2.2 configuration summary .....................................................................................6 3 package and pinout ................. ................ ................. ................ ............... 8 3.1 package .............................................................................................................8 3.2 peripheral multiplexing on i/o lines .................................................................18 3.3 signals description ..........................................................................................30 3.4 i/o line considerations ...................................................................................33 4 cortex-m4 processor and core peripherals ... .............. .............. .......... 35 4.1 cortex-m4 ........................................................................................................35 4.2 system level interface .....................................................................................36 4.3 integrated configurable debug .........................................................................36 4.4 cortex-m4 processor features and benefits summary .....................................37 4.5 cortex-m4 core peripherals .............................................................................37 4.6 cortex-m4 implementations options ................................................................38 4.7 cortex-m4 interrupts map ................................................................................38 4.8 peripheral debug .............................................................................................41 5 power and startup considerat ions ........ ................. ................ ............. 42 5.1 power domain overview .................................................................................42 5.2 power supplies ................................................................................................44 5.3 startup considerations ....................................................................................49 5.4 power-on-reset, brownout and supply monitor .............................................49 6 low power techniques ........... ................ ................. ................ ............. 51 6.1 power save modes .........................................................................................51 6.2 power scaling ..................................................................................................56 7 memories ............... .............. .............. ............... .............. .............. .......... 58 7.1 product mapping .............................................................................................58 7.2 embedded memories ......................................................................................59 7.3 physical memory map .....................................................................................59
1194 42023e?sam?07/2013 atsam4l8/l4/l2 8 debug and test ................. ................ ............... .............. .............. .......... 61 8.1 features ..........................................................................................................61 8.2 overview ..........................................................................................................61 8.3 block diagram .................................................................................................62 8.4 i/o lines description .......................................................................................62 8.5 product dependencies ....................................................................................63 8.6 core debug .....................................................................................................63 8.7 enhanced debug port (edp) ..........................................................................66 8.8 system manager access port (smap) ............................................................76 8.9 ahb-ap access port .......................................................................................91 8.10 available features in protected state .............................................................92 8.11 functional description .....................................................................................93 9 chip identifier (chipid) .... ................ ............... .............. .............. .......... 98 9.1 description .......................................................................................................98 9.2 embedded characteristics ..............................................................................98 9.3 user interface ...............................................................................................100 10 power manager (pm) ......... .............. .............. .............. .............. ........... 108 10.1 features ........................................................................................................108 10.2 overview ........................................................................................................108 10.3 block diagram ...............................................................................................108 10.4 i/o lines description .....................................................................................109 10.5 product dependencies ..................................................................................109 10.6 functional description ...................................................................................109 10.7 user interface ................................................................................................115 10.8 module configuration ....................................................................................138 11 backup power manager (bpm) . ................. ................ .............. ........... 139 11.1 features ........................................................................................................139 11.2 overview ........................................................................................................139 11.3 block diagram ...............................................................................................140 11.4 product dependencies ..................................................................................140 11.5 functional description ...................................................................................141 11.6 user interface ................................................................................................144 11.7 module configuration ....................................................................................159 12 backup system control inte rface (bscif) ............. ................ ........... 160 12.1 features ........................................................................................................160
1195 42023e?sam?07/2013 atsam4l8/l4/l2 12.2 overview ........................................................................................................160 12.3 block diagram ...............................................................................................161 12.4 i/o lines description .....................................................................................161 12.5 product dependencies ..................................................................................162 12.6 functional description ...................................................................................162 12.7 user interface ................................................................................................171 12.8 module configuration ....................................................................................201 13 system control interface (sci f) ........... ................. ................ ............. 202 13.1 features ........................................................................................................202 13.2 overview ........................................................................................................202 13.3 block diagram ...............................................................................................202 13.4 i/o lines description .....................................................................................203 13.5 product dependencies ..................................................................................203 13.6 functional description ...................................................................................203 13.7 user interface ................................................................................................219 13.8 module configuration ....................................................................................258 14 flash controller (flashcalw) ............. ................. ................ ........... 262 14.1 features ........................................................................................................262 14.2 overview ........................................................................................................262 14.3 block diagram ...............................................................................................263 14.4 product dependencies ..................................................................................263 14.5 functional description ...................................................................................265 14.6 flash commands ..........................................................................................274 14.7 general-purpose fuse bits ............................................................................276 14.8 security fuses ...............................................................................................277 14.9 error correcting code ...................................................................................277 14.10 user interface ................................................................................................279 14.11 fuse settings .................................................................................................298 14.12 serial number ................................................................................................302 14.13 module configuration ....................................................................................302 15 hsb bus matrix (hmatrixb) ................ ................. ................ ............. 304 15.1 features ........................................................................................................304 15.2 overview ........................................................................................................304 15.3 product dependencies ..................................................................................304 15.4 functional description ...................................................................................304
1196 42023e?sam?07/2013 atsam4l8/l4/l2 15.5 user interface ................................................................................................308 15.6 module configuration ....................................................................................316 16 peripheral dma controller (pdca) ............. .............. .............. ........... 318 16.1 features ........................................................................................................318 16.2 overview ........................................................................................................318 16.3 block diagram ...............................................................................................319 16.4 product dependencies ..................................................................................319 16.5 functional description ...................................................................................320 16.6 user interface ................................................................................................323 16.7 module configuration ....................................................................................337 17 usb device and embedded host interface (usbc) .... .............. ........ 340 17.1 features ........................................................................................................340 17.2 overview ........................................................................................................340 17.3 block diagram ...............................................................................................340 17.4 i/o lines description .....................................................................................342 17.5 product dependencies ..................................................................................343 17.6 functional description ...................................................................................344 17.7 user interface ................................................................................................370 17.8 module configuration ....................................................................................427 18 advanced encryption standard (aesa) .......... .............. ............ ........ 428 18.1 features ........................................................................................................428 18.2 overview ........................................................................................................428 18.3 product dependencies ..................................................................................429 18.4 functional description ...................................................................................429 18.5 user interface ................................................................................................434 18.6 module configuration ....................................................................................450 19 asynchronous timer (ast) ...... ................. ................ .............. ........... 451 19.1 features ........................................................................................................451 19.2 overview ........................................................................................................451 19.3 block diagram ...............................................................................................452 19.4 product dependencies ..................................................................................452 19.5 functional description ...................................................................................453 19.6 user interface ................................................................................................459 19.7 module configuration ....................................................................................480
1197 42023e?sam?07/2013 atsam4l8/l4/l2 20 watchdog timer (wdt) ......... ................ ................. ................ ............. 481 20.1 features ........................................................................................................481 20.2 overview ........................................................................................................481 20.3 block diagram ...............................................................................................481 20.4 product dependencies ..................................................................................481 20.5 functional description ...................................................................................482 20.6 user interface ................................................................................................489 20.7 module configuration ....................................................................................500 21 external interrupt controller (eic) ..... .............. .............. ............ ........ 501 21.1 features ........................................................................................................501 21.2 overview ........................................................................................................501 21.3 block diagram ...............................................................................................501 21.4 i/o lines description .....................................................................................502 21.5 product dependencies ..................................................................................502 21.6 functional description ...................................................................................502 21.7 user interface ................................................................................................506 21.8 module configuration ....................................................................................522 22 frequency meter (freqm) ...... ................ ................. ................ ........... 523 22.1 features ........................................................................................................523 22.2 overview ........................................................................................................523 22.3 block diagram ...............................................................................................523 22.4 product dependencies ..................................................................................523 22.5 functional description ...................................................................................524 22.6 user interface ................................................................................................526 22.7 module configuration ....................................................................................537 23 general-purpose input/output controller (gpio) .... .............. ........... 539 23.1 features ........................................................................................................539 23.2 overview ........................................................................................................539 23.3 block diagram ...............................................................................................539 23.4 i/o lines description .....................................................................................540 23.5 product dependencies ..................................................................................540 23.6 functional description ...................................................................................541 23.7 user interface ................................................................................................547 23.8 module configuration ....................................................................................572 24 universal synchro nous asynchronous receiver tr ansmitter (usart)
1198 42023e?sam?07/2013 atsam4l8/l4/l2 574 24.1 features ........................................................................................................574 24.2 overview ........................................................................................................574 24.3 block diagram ...............................................................................................575 24.4 i/o lines description ....................................................................................577 24.5 product dependencies ..................................................................................577 24.6 functional description ...................................................................................578 24.7 user interface ................................................................................................621 24.8 module configuration ....................................................................................651 25 picopower uart (pic ouart) ................ ................. ................ ........... 652 25.1 features ........................................................................................................652 25.2 overview ........................................................................................................652 25.3 block diagram ...............................................................................................652 25.4 i/o lines description .....................................................................................653 25.5 product dependencies ..................................................................................653 25.6 functional description ...................................................................................653 25.7 user interface ................................................................................................656 25.8 module configuration ....................................................................................662 26 serial peripheral interface (spi) ................ ................ .............. ........... 663 26.1 features ........................................................................................................663 26.2 overview ........................................................................................................663 26.3 block diagram ...............................................................................................664 26.4 application block diagram .............................................................................664 26.5 i/o lines description .....................................................................................665 26.6 product dependencies ..................................................................................665 26.7 functional description ...................................................................................665 26.8 user interface ................................................................................................676 26.9 module configuration ....................................................................................703 27 two-wire master interface (twim) ........ ................. ................ ............. 704 27.1 features ........................................................................................................704 27.2 overview ........................................................................................................704 27.3 list of abbreviations ......................................................................................705 27.4 block diagram ...............................................................................................705 27.5 application block diagram .............................................................................706 27.6 i/o lines description .....................................................................................706
1199 42023e?sam?07/2013 atsam4l8/l4/l2 27.7 product dependencies ..................................................................................706 27.8 functional description ...................................................................................708 27.9 user interface ................................................................................................722 27.10 module configuration ....................................................................................742 28 two-wire slave interface (twis) ........... ................. ................ ............. 743 28.1 features ........................................................................................................743 28.2 overview ........................................................................................................743 28.3 list of abbreviations ......................................................................................744 28.4 block diagram ...............................................................................................744 28.5 application block diagram .............................................................................745 28.6 i/o lines description .....................................................................................745 28.7 product dependencies ..................................................................................745 28.8 functional description ...................................................................................746 28.9 user interface ................................................................................................757 28.10 module configuration ....................................................................................776 29 inter-ic sound controller (i isc) ............ ................. ................ ............. 777 29.1 features ........................................................................................................777 29.2 overview ........................................................................................................777 29.3 block diagram ...............................................................................................778 29.4 i/o lines description .....................................................................................778 29.5 product dependencies ..................................................................................778 29.6 functional description ...................................................................................779 29.7 iisc application examples ............................................................................784 29.8 user interface ................................................................................................786 29.9 module configuration ....................................................................................800 30 timer/counter (tc) ........... .............. .............. .............. .............. ........... 801 30.1 features ........................................................................................................801 30.2 overview ........................................................................................................801 30.3 block diagram ..............................................................................................802 30.4 i/o lines description .....................................................................................802 30.5 product dependencies ..................................................................................802 30.6 functional description ...................................................................................803 30.7 2-bit gray up/down counter for stepper motor ............................................817 30.8 write protection system ................................................................................817 30.9 user interface ................................................................................................818
1200 42023e?sam?07/2013 atsam4l8/l4/l2 30.10 module configuration ....................................................................................843 31 peripheral event controller (pevc) ............ .............. .............. ........... 844 31.1 features ........................................................................................................844 31.2 overview ........................................................................................................844 31.3 block diagram ...............................................................................................845 31.4 i/o lines description .....................................................................................846 31.5 product dependencies ..................................................................................846 31.6 functional description ...................................................................................849 31.7 application example ......................................................................................851 31.8 user interface ................................................................................................852 31.9 module configuration ....................................................................................873 32 audio bit stream da c (abdacb) .......... ................. ................ ........... 876 32.1 features ........................................................................................................876 32.2 overview ........................................................................................................876 32.3 block diagram ...............................................................................................876 32.4 i/o lines description .....................................................................................877 32.5 product dependencies ..................................................................................877 32.6 functional description ...................................................................................878 32.7 user interface ................................................................................................885 32.8 module configuration ....................................................................................899 33 digital to analog converte r controller (dacc) ...... ................ ........... 900 33.1 features ........................................................................................................900 33.2 overview ........................................................................................................900 33.3 block diagram ...............................................................................................901 33.4 signal description ..........................................................................................901 33.5 product dependencies ..................................................................................901 33.6 functional description ...................................................................................902 33.7 user interface ................................................................................................904 33.8 module configuration ....................................................................................915 34 capacitive touch module (cat b) ............... .............. .............. ........... 916 34.1 features ........................................................................................................916 34.2 overview ........................................................................................................916 34.3 block diagram ...............................................................................................917 34.4 i/o lines description .....................................................................................917 34.5 product dependencies ..................................................................................917
1201 42023e?sam?07/2013 atsam4l8/l4/l2 34.6 functional description ...................................................................................918 34.7 user interface ................................................................................................927 34.8 module configuration ....................................................................................949 35 true random number generator (trng) .. ............... .............. ........... 950 35.1 features ........................................................................................................950 35.2 overview ........................................................................................................950 35.3 functional description ...................................................................................950 35.4 user interface ................................................................................................951 35.5 module configuration ....................................................................................959 36 glue logic controller (gloc) .............. ................. ................ ............. 960 36.1 features ........................................................................................................960 36.2 overview ........................................................................................................960 36.3 block diagram ...............................................................................................960 36.4 i/o lines description .....................................................................................961 36.5 product dependencies ..................................................................................961 36.6 functional description ...................................................................................961 36.7 user interface ................................................................................................963 36.8 module configuration ....................................................................................968 37 analog comparator interface (acifc) ........ .............. .............. ........... 969 37.1 features ........................................................................................................969 37.2 overview ........................................................................................................969 37.3 block diagram ...............................................................................................970 37.4 i/o lines description .....................................................................................970 37.5 product dependencies ..................................................................................971 37.6 functional description ...................................................................................971 37.7 peripheral event triggers ..............................................................................977 37.8 ac test mode ................................................................................................977 37.9 user interface ................................................................................................978 37.10 module configuration .....................................................................................993 38 adc interface (adcife) .... ............. .............. .............. .............. ........... 994 38.1 features ........................................................................................................994 38.2 overview ........................................................................................................994 38.3 block diagram ................................................................................................995 38.4 i/o lines description .....................................................................................995 38.5 product dependencies ...................................................................................995
1202 42023e?sam?07/2013 atsam4l8/l4/l2 38.6 section 42. ?electrical characteristics? on page 1120 functional description ..... 996 38.7 user interface ..............................................................................................1004 38.8 module configuration ..................................................................................1031 39 lcd controller (lcdca) .... ................. ................ ................. ............. 1032 39.1 features ......................................................................................................1032 39.2 overview ......................................................................................................1032 39.3 block diagram .............................................................................................1033 39.4 i/o lines description ...................................................................................1033 39.5 product dependencies ................................................................................1033 39.6 functional description .................................................................................1034 39.7 user interface ..............................................................................................1053 39.8 module configuration ..................................................................................1077 40 parallel capture (parc) .... ............. .............. .............. .............. ......... 1080 40.1 features ......................................................................................................1080 40.2 overview ......................................................................................................1080 40.3 block diagram .............................................................................................1080 40.4 i/o lines description ...................................................................................1080 40.5 product dependencies ................................................................................1080 40.6 functional description .................................................................................1081 40.7 user interface ..............................................................................................1084 40.8 module configuration ..................................................................................1095 41 cyclic redundancy check calculation unit (crccu) ................... 1096 41.1 features ......................................................................................................1096 41.2 overview ......................................................................................................1096 41.3 block diagram .............................................................................................1096 41.4 product dependencies ................................................................................1096 41.5 functional description .................................................................................1097 41.6 user interface ..............................................................................................1099 41.7 module configuration ..................................................................................1119 42 electrical characteristics ... ................. ................ ................. ............. 1120 42.1 absolute maximum ratings* .......................................................................1120 42.2 operating conditions ...................................................................................1120 42.3 supply characteristics .................................................................................1120 42.4 maximum clock frequencies ......................................................................1122
1203 42023e?sam?07/2013 atsam4l8/l4/l2 42.5 power consumption ....................................................................................1124 42.6 i/o pin characteristics .................................................................................1135 42.7 oscillator characteristics .............................................................................1142 42.8 flash characteristics ...................................................................................1148 42.9 analog characteristics .................................................................................1150 42.10 timing characteristics .................................................................................1161 43 mechanical characteristics ..... ................ ................. .............. ........... 1174 43.1 thermal considerations ..............................................................................1174 43.2 package drawings .......................................................................................1175 43.3 soldering profile ..........................................................................................1184 44 ordering information .......... ................. ................ ................. ............. 1185 45 errata ........... ................ ................ ................. .............. .............. ........... 1188 45.1 atsam4l4 /2 rev. b & atsam4l8 rev. a ................................................1188 46 datasheet revision history ................ ................ ................. ............. 1191 46.1 rev. a ? 09/12 .............................................................................................1191 46.2 rev. b ? 10/12 .............................................................................................1191 46.3 rev. c ? 02/13 .............................................................................................1191 46.4 rev. d ? 03/13 .............................................................................................1191 46.5 rev. e ? 07/13 .............................................................................................1192 table of contents........ ................ ................. .............. .............. ........... 1193
42023e?sam?07/2013 atmel corporation 2325 orchard parkway san jose, ca 95131 usa tel : (+1)(408) 441-0311 fax : (+1)(408) 487-2600 www.atmel.com atmel asia limited unit 1-5 & 16, 19/f bea tower, millennium city 5 418 kwun tong road kwun tong, kowloon hong kong tel : (+852) 2245-6100 fax : (+852) 2722-1369 atmel munich gmbh business campus parkring 4 d-85748 garching b. munich germany tel : (+49) 89-31970-0 fax : (+49) 89-3194621 atmel japan 16f, shin osaki kangyo bldg. 1-6-4 osaka shinagawa-ku tokyo 104-0032 japan tel : (+81) 3-6417-0300 fax : (+81) 3-6417-0370 ? 2013 atmel corporation. all rights reserved. 124152 atmel ? , atmel logo and combinations thereof, picopower ? , adjacent key suppression ? ,aks ? , qtouch ? , and others are registered trademarks or trademarks of atmel co rporation or its subsidiaries. arm ? , amba ? ,thumb ? , cortex tm are registered trademarks or trademarks of arm ltd. other terms and product names may be trademarks of others. disclaimer: the information in this document is provided in connection wi th atmel products. no license, ex press or implied, by estoppel or otherwise, to any intellectual property right is granted by this document or in connection with the sale of atmel products. except as set forth in the atmel terms and conditions of sales located on the atmel website, atmel assumes no liability whatsoever and disclaims any express, implied or statutory warranty relating to its pro ducts including, but not limited to, the implied warranty of merchantability, fitness for a particular purp ose, or non-infringement. in no even t shall atmel be liable for any direct, indirect, consequential, punitive, special or incidental damages (including, without limitati on, damages for loss and prof- its, business interruption, or loss of information) arising out of the use or inability to use this document, even if atmel has been advised of the possibility of such damages. atmel makes no representations or warranties with respect to the accuracy or com- pleteness of the contents of th is document and reserves the right to make changes to specifications and product descriptions at any time without notice. atmel does not make any commitment to update the information cont ained herein. unless specifically provided otherwise, atmel pr oducts are not suit- able for, and shall not be used in, automotive applications. atme l products are not intended, authorized, or warranted for use as components in applica- tions intended to support or sustain life.


▲Up To Search▲   

 
Price & Availability of TSC80C31-30CFB

All Rights Reserved © IC-ON-LINE 2003 - 2022  

[Add Bookmark] [Contact Us] [Link exchange] [Privacy policy]
Mirror Sites :  [www.datasheet.hk]   [www.maxim4u.com]  [www.ic-on-line.cn] [www.ic-on-line.com] [www.ic-on-line.net] [www.alldatasheet.com.cn] [www.gdcy.com]  [www.gdcy.net]


 . . . . .
  We use cookies to deliver the best possible web experience and assist with our advertising efforts. By continuing to use this site, you consent to the use of cookies. For more information on cookies, please take a look at our Privacy Policy. X